コード例 #1
0
ファイル: rec_usrp.py プロジェクト: cbeighley/peregrine
    def __init__(self, filename, dev_addrs,
                 onebit, gain, digital_gain, fs, fc, sync_pps):
        gr.top_block.__init__(self)

        if onebit:
            raise NotImplementedError("TODO: 1-bit mode not implemented.")
        
        uhd_srcs = [
            uhd.usrp_source(",".join(
                [addr, "num_recv_frames=256,recv_frame_size=16384"]),
                          uhd.stream_args(
                              cpu_format="fc32",
                              otwformat="sc16",
                              channels=[0]))
            for addr in dev_addrs]

        str2vec = blocks.streams_to_vector(2, len(uhd_srcs))
        self.connect(str2vec,
                     blocks.stream_to_vector(2 * len(uhd_srcs), 16*1024*1024),
                     blocks.file_sink(2 * len(uhd_srcs) * 16 * 1024 * 1024, filename, False))
        
        for ix, src in enumerate(uhd_srcs):
            src.set_clock_rate(fs*2, uhd.ALL_MBOARDS)
            src.set_samp_rate(fs)
            src.set_center_freq(uhd.tune_request(fc, 3e6))
            src.set_gain(gain, 0)
            # TODO Use offset tuning?
            if sync_pps:
                src.set_clock_source("external") # 10 MHz
                src.set_time_source("external") # PPS

            self.connect(src,  # [-1.0, 1.0]
                         blocks.multiply_const_cc(32767 * digital_gain[ix]), # [-32767.0, 32767.0]
                         blocks.complex_to_interleaved_short(), #[-32768, 32767]
                         blocks.short_to_char(), #[-128, 127]
                         blocks.stream_to_vector(1, 2), # I,Q,I,Q -> IQ, IQ
                         (str2vec, ix))

        print "Setting clocks..."
        if sync_pps:
            time.sleep(1.1) # Ensure there's been an edge.  TODO: necessary?
            last_pps_time = uhd_srcs[0].get_time_last_pps()
            while last_pps_time == uhd_srcs[0].get_time_last_pps():
                time.sleep(0.1)
            print "Got edge"
            [src.set_time_next_pps(uhd.time_spec(round(time.time())+1)) for src in uhd_srcs]
            time.sleep(1.0) # Wait for edge to set the clocks
        else:
            # No external PPS/10 MHz.  Just set each clock and accept some skew.
            t = time.time()
            [src.set_time_now(uhd.time_spec(time.time())) for src in uhd_srcs]
            if len(uhd_srcs) > 1:
                print "Uncabled; loosely synced only. Initial skew ~ %.1f ms" % (
                    (time.time()-t) * 1000)

        t_start = uhd.time_spec(time.time() + 1.5)
        [src.set_start_time(t_start) for src in uhd_srcs]
        print "ready"
コード例 #2
0
ファイル: receiver.py プロジェクト: luwangg/gr-localization
 def sync_time_nmea(self):
     print "Begin time sync"
     if self.gps == "octoclock":
         clock = octoclock.multi_usrp_clock()
     # get time of last pps from USRP
     last_pps_time = self.usrp_source.get_time_last_pps().get_real_secs()
     print "Last pps time before sync:", last_pps_time
     synced = False
     while not synced:
         if (self.gps == "ltelite") or (self.gps == "leam8f"):
             while self.nmea_external is "":
                 time.sleep(0.1)
             self.nmea_external_lock.acquire()
             s = self.nmea_external
             self.nmea_external_lock.release()
             t = s.split(",")[1].split(".")[0]
             d = s.split(",")[9]
             my_time = time.strptime(t+d,"%H%M%S%d%m%y")
             time_nmea = calendar.timegm(my_time)
             self.usrp_source.set_time_next_pps(uhd.time_spec(time_nmea + 1))
             if self.options.ntp_server and time_nmea > 1400000000:
                 os.system("sudo date +%s -s @"+str(time_nmea))
                 print "System time set to:", str(time_nmea)
             print "Set USRP to NMEA time + 1s:", time_nmea + 1
             synced = True
         else:
             # check for occurence of next pps
             last_pps_time_check = self.usrp_source.get_time_last_pps().get_real_secs()
             print "Check last pps time:", last_pps_time_check
             if last_pps_time_check > last_pps_time:
                 # get pps time from NMEA and set time of next pps
                 if self.gps == "octoclock":
                     time_nmea = clock.get_time_real_secs()
                 else:
                     time_nmea = [int(s) for s in self.usrp_source.get_mboard_sensor("gps_time",0).to_pp_string().split() if s.isdigit()][0]
                 # set internal time registers in USRP
                 self.usrp_source.set_time_next_pps(uhd.time_spec(time_nmea + 1))
                 # set system time if ntp server option activated
                 if self.options.ntp_server and time_nmea > 1400000000:
                     os.system("sudo date +%s -s @"+str(time_nmea))
                     print "System time set to:", str(time_nmea)
                 print "Set USRP to NMEA time + 1s:", time_nmea + 1
                 synced = True
             else:
                 # sleep for 100 msec
                 time.sleep(0.1)
     print "Just after NMEA sync: ", self.usrp_source.get_time_last_pps().get_real_secs()
     time.sleep(1)
     print "After 1s: ", self.usrp_source.get_time_last_pps().get_real_secs()
     print "NMEA time sync complete!"
     if self.options.ntp_server:
         self.rpc_manager.request("sync_ntp",[self.ip_addr])
コード例 #3
0
ファイル: uhd_app.py プロジェクト: sgardner340/gnuradio
 def set_freq(self, freq, skip_sync=False):
     """
     Safely tune all channels to freq.
     """
     self.vprint("Tuning all channels to {freq} MHz.".format(freq=freq/1e6))
     # Set frequency (tune request takes lo_offset):
     if hasattr(self.args, 'lo_offset') and self.args.lo_offset is not None:
         treq = uhd.tune_request(freq, self.args.lo_offset)
     else:
         treq = uhd.tune_request(freq)
     # Make sure tuning is synched:
     if len(self.channels) > 1 and not skip_sync:
         cmd_time = self.usrp.get_time_now() + uhd.time_spec(COMMAND_DELAY)
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.set_command_time(cmd_time, mb_idx)
     for chan in self.channels:
         self.tr = self.usrp.set_center_freq(treq, chan)
         if self.tr == None:
             sys.stderr.write('[{prefix}] [ERROR] Failed to set center frequency on channel {chan}\n'.format(
                 prefix=self.prefix, chan=chan
             ))
             exit(1)
     if len(self.channels) > 1 and not skip_sync:
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.clear_command_time(mb_idx)
         self.vprint("Syncing channels...".format(prefix=self.prefix))
         time.sleep(COMMAND_DELAY)
     self.freq = self.usrp.get_center_freq(self.channels[1])
     self.vprint("First channel has freq: {freq} MHz.".format(freq=self.freq/1e6))
コード例 #4
0
ファイル: uhd_modes.py プロジェクト: kd5bwt/gr-air-modes
  def __init__(self, options, args, queue):
    gr.top_block.__init__(self)

    self.options = options
    self.args = args
    rate = int(options.rate)

    if options.filename is None:
      self.u = uhd.single_usrp_source("", uhd.io_type_t.COMPLEX_FLOAT32, 1)
      time_spec = uhd.time_spec(0.0)
      self.u.set_time_now(time_spec)

      #if(options.rx_subdev_spec is None):
      #  options.rx_subdev_spec = ""
      #self.u.set_subdev_spec(options.rx_subdev_spec)
      if not options.antenna is None:
        self.u.set_antenna(options.antenna)

      self.u.set_samp_rate(rate)
      rate = int(self.u.get_samp_rate()) #retrieve actual

      if options.gain is None: #set to halfway
        g = self.u.get_gain_range()
        options.gain = (g.start()+g.stop()) / 2.0

      if not(self.tune(options.freq)):
        print "Failed to set initial frequency"

      print "Setting gain to %i" % (options.gain,)
      self.u.set_gain(options.gain)
      print "Gain is %i" % (self.u.get_gain(),)

    else:
      self.u = gr.file_source(gr.sizeof_gr_complex, options.filename)

    print "Rate is %i" % (rate,)

    pass_all = 0
    if options.output_all :
      pass_all = 1

    self.demod = gr.complex_to_mag()
    self.avg = gr.moving_average_ff(100, 1.0/100, 400)
    
    #the DBSRX especially tends to be spur-prone; the LPF keeps out the
    #spur multiple that shows up at 2MHz
    self.lpfiltcoeffs = gr.firdes.low_pass(1, rate, 1.8e6, 100e3)
    self.lpfilter = gr.fir_filter_ccf(1, self.lpfiltcoeffs)
    
    self.preamble = air.modes_preamble(rate, options.threshold)
    #self.framer = air.modes_framer(rate)
    self.slicer = air.modes_slicer(rate, queue)
    
    self.connect(self.u, self.lpfilter, self.demod)
    self.connect(self.demod, self.avg)
    self.connect(self.demod, (self.preamble, 0))
    self.connect(self.avg, (self.preamble, 1))
    self.connect((self.preamble, 0), (self.slicer, 0))
コード例 #5
0
def main():
    """ Go, go, go! """
    args = setup_parser().parse_args()
    if (1.0 * args.samp_per_burst / args.rate) > args.hop_time * 1e-3:
        print "Burst duration must be smaller than hop time."
        exit(1)
    if args.verbose:
        print_hopper_stats(args)
    top_block = FlowGraph(args)
    print "Starting to hop, skip and jump... press Ctrl+C to exit."
    top_block.u.set_time_now(uhd.time_spec(0.0))
    top_block.run()
コード例 #6
0
ファイル: uhd_app.py プロジェクト: Stefan-Olt/gnuradio
    def set_freq(self, freq, skip_sync=False):
        """
        Safely tune all channels to freq.
        """
        self.vprint("Tuning all channels to {freq} MHz.".format(freq=freq/1e6))
        # Set frequency (tune request takes lo_offset):
        if hasattr(self.args, 'lo_offset') and self.args.lo_offset is not None:
            treq = uhd.tune_request(freq, self.args.lo_offset)
        else:
            treq = uhd.tune_request(freq)
        # Special TwinRX tuning due to LO sharing
        if getattr(self, 'lo_source_channel', None) is not None:
            tune_resp = self.usrp.set_center_freq(treq, self.lo_source_channel)
            if getattr(self.args, 'lo_offset', None) is not None:
                treq = uhd.tune_request(target_freq=freq, rf_freq=freq+self.args.lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL,
                                        dsp_freq=tune_resp.actual_dsp_freq,
                                        dsp_freq_policy=uhd.tune_request.POLICY_MANUAL)
            else:
                treq = uhd.tune_request(target_freq=freq, rf_freq=freq, rf_freq_policy=uhd.tune_reqest.POLICY_MANUAL,
                                        dsp_freq=tune_resp.actual_dsp_freq,
                                        dsp_freq_policy=uhd.tune_request.POLICY_MANUAL)
            for chan in self.channels:
                if chan == self.lo_source_channel:
                    continue
                self.usrp.set_center_freq(treq,chan)

        # Make sure tuning is synched:
        command_time_set = False
        if len(self.channels) > 1 and not skip_sync:
            cmd_time = self.usrp.get_time_now() + uhd.time_spec(COMMAND_DELAY)
            try:
                for mb_idx in xrange(self.usrp.get_num_mboards()):
                    self.usrp.set_command_time(cmd_time, mb_idx)
                command_time_set = True
            except RuntimeError:
                sys.stderr.write('[{prefix}] [WARNING] Failed to set command times.\n'.format(prefix=self.prefix))
        for i, chan in enumerate(self.channels ):
            self.tr = self.usrp.set_center_freq(treq, i)
            if self.tr == None:
                sys.stderr.write('[{prefix}] [ERROR] Failed to set center frequency on channel {chan}\n'.format(
                    prefix=self.prefix, chan=chan
                ))
                exit(1)
        if command_time_set:
            for mb_idx in xrange(self.usrp.get_num_mboards()):
                self.usrp.clear_command_time(mb_idx)
            self.vprint("Syncing channels...".format(prefix=self.prefix))
            time.sleep(COMMAND_DELAY)
        self.freq = self.usrp.get_center_freq(0)
        self.vprint("First channel has freq: {freq} MHz.".format(freq=self.freq/1e6))
コード例 #7
0
    def __init__(self, radio_id='USRP', sat_name='SIM'):
        gr.top_block.__init__(self, "/home/zleffke/captures/misc/SIM_USRP_20190906_194852.435803_UTC_250k.fc32")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("/home/zleffke/captures/misc/SIM_USRP_20190906_194852.435803_UTC_250k.fc32")
        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", "usrp_record")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.radio_id = radio_id
        self.sat_name = sat_name

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S.%f" )+'_UTC'
        self.samp_rate = samp_rate = 250e3
        self.fn = fn = "{:s}_{:s}_{:s}_{:s}k.fc32".format(sat_name, radio_id, ts_str, str(int(samp_rate)/1000))

        self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, samp_rate/2, 1000, firdes.WIN_HAMMING, 6.76)

        self.volume = volume = 0.01
        self.rx_gain = rx_gain = 50
        self.rx_freq = rx_freq = 440.389e6
        self.offset = offset = 0e3
        self.fsk_deviation_hz = fsk_deviation_hz = 4000
        self.fp = fp = "/home/zleffke/captures/misc/{:s}".format(fn)
        self.decim = decim = 5
        self.audio_lpf_cutoff = audio_lpf_cutoff = 7e3

        ##################################################
        # Blocks
        ##################################################
        self._volume_tool_bar = Qt.QToolBar(self)
        self._volume_tool_bar.addWidget(Qt.QLabel("volume"+": "))
        self._volume_line_edit = Qt.QLineEdit(str(self.volume))
        self._volume_tool_bar.addWidget(self._volume_line_edit)
        self._volume_line_edit.returnPressed.connect(
        	lambda: self.set_volume(eng_notation.str_to_num(str(self._volume_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._volume_tool_bar, 10, 2, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel('GAIN'+": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(
        	lambda: self.set_rx_gain(eng_notation.str_to_num(str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 10, 0, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ'+": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(
        	lambda: self.set_rx_freq(eng_notation.str_to_num(str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 10, 1, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel('OFFSET'+": "))
        self._offset_line_edit = Qt.QLineEdit(str(self.offset))
        self._offset_tool_bar.addWidget(self._offset_line_edit)
        self._offset_line_edit.returnPressed.connect(
        	lambda: self.set_offset(eng_notation.str_to_num(str(self._offset_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._offset_tool_bar)
        self._audio_lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._audio_lpf_cutoff_tool_bar.addWidget(Qt.QLabel("audio_lpf_cutoff"+": "))
        self._audio_lpf_cutoff_line_edit = Qt.QLineEdit(str(self.audio_lpf_cutoff))
        self._audio_lpf_cutoff_tool_bar.addWidget(self._audio_lpf_cutoff_line_edit)
        self._audio_lpf_cutoff_line_edit.returnPressed.connect(
        	lambda: self.set_audio_lpf_cutoff(eng_notation.str_to_num(str(self._audio_lpf_cutoff_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_lpf_cutoff_tool_bar, 10, 3, 1, 2)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_1_0 = uhd.usrp_source(
        	",".join(("serial=30CF9AD", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_1_0.set_subdev_spec('A:A', 0)
        self.uhd_usrp_source_1_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_1_0.set_center_freq(uhd.tune_request(rx_freq, samp_rate/2), 0)
        self.uhd_usrp_source_1_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_1_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_1_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_1_0.set_auto_iq_balance(True, 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

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

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 6, 0, 2, 6)
        for r in range(6, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate / decim / 50 * 48, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8, 0, 2, 6)
        for r in range(8, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 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, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -40)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(True)

        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 6, 6)
        for r in range(0, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0_0_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, samp_rate/decim/50*48, audio_lpf_cutoff, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(decim, firdes.low_pass(
        	1, samp_rate, 25e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (xlate_taps), offset, samp_rate)
        self.fosphor_glfw_sink_c_0 = fosphor.glfw_sink_c()
        self.fosphor_glfw_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_glfw_sink_c_0.set_frequency_range(0, samp_rate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(samp_rate/(2*math.pi*fsk_deviation_hz/8.0))



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.uhd_usrp_source_1_0, 0), (self.fosphor_glfw_sink_c_0, 0))
        self.connect((self.uhd_usrp_source_1_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
コード例 #8
0
ファイル: top_block.py プロジェクト: WiLab/gr-wifius
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.variable_qtgui_chooser_0_0_0 = variable_qtgui_chooser_0_0_0 = 1
        self.variable_qtgui_chooser_0_0 = variable_qtgui_chooser_0_0 = 1
        self.snapshots = snapshots = 4096
        self.samp_rate = samp_rate = 100000000/32
        self.pi = pi = 3.14159265359
        self.phase_c2 = phase_c2 = 0
        self.phase_c1 = phase_c1 = 0
        self.phase_c0 = phase_c0 = 0
        self.gain_rx = gain_rx = 20
        self.center_freq = center_freq = 2.4e9
        self.ant_cal_enable = ant_cal_enable = 1

        ##################################################
        # Blocks
        ##################################################
        _variable_qtgui_chooser_0_0_0_check_box = Qt.QCheckBox("TX OTA (Bottom) ")
        self._variable_qtgui_chooser_0_0_0_choices = {True: 0, False: 1}
        self._variable_qtgui_chooser_0_0_0_choices_inv = dict((v,k) for k,v in self._variable_qtgui_chooser_0_0_0_choices.iteritems())
        self._variable_qtgui_chooser_0_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(_variable_qtgui_chooser_0_0_0_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_chooser_0_0_0_choices_inv[i]))
        self._variable_qtgui_chooser_0_0_0_callback(self.variable_qtgui_chooser_0_0_0)
        _variable_qtgui_chooser_0_0_0_check_box.stateChanged.connect(lambda i: self.set_variable_qtgui_chooser_0_0_0(self._variable_qtgui_chooser_0_0_0_choices[bool(i)]))
        self.top_grid_layout.addWidget(_variable_qtgui_chooser_0_0_0_check_box, 1,0)
        _variable_qtgui_chooser_0_0_check_box = Qt.QCheckBox("TX Direct (Top)")
        self._variable_qtgui_chooser_0_0_choices = {True: 0, False: 1}
        self._variable_qtgui_chooser_0_0_choices_inv = dict((v,k) for k,v in self._variable_qtgui_chooser_0_0_choices.iteritems())
        self._variable_qtgui_chooser_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(_variable_qtgui_chooser_0_0_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_chooser_0_0_choices_inv[i]))
        self._variable_qtgui_chooser_0_0_callback(self.variable_qtgui_chooser_0_0)
        _variable_qtgui_chooser_0_0_check_box.stateChanged.connect(lambda i: self.set_variable_qtgui_chooser_0_0(self._variable_qtgui_chooser_0_0_choices[bool(i)]))
        self.top_grid_layout.addWidget(_variable_qtgui_chooser_0_0_check_box, 0,0)
        self._phase_c2_range = Range(-180, 180, 1, 0, 200)
        self._phase_c2_win = RangeWidget(self._phase_c2_range, self.set_phase_c2, "Phase Channel2", "counter_slider", float)
        self.top_layout.addWidget(self._phase_c2_win)
        self._phase_c1_range = Range(-180, 180, 1, 0, 200)
        self._phase_c1_win = RangeWidget(self._phase_c1_range, self.set_phase_c1, "Phase Channel1", "counter_slider", float)
        self.top_layout.addWidget(self._phase_c1_win)
        self._phase_c0_range = Range(-180, 180, 1, 0, 200)
        self._phase_c0_win = RangeWidget(self._phase_c0_range, self.set_phase_c0, "Phase Channel0", "counter_slider", float)
        self.top_layout.addWidget(self._phase_c0_win)
        _ant_cal_enable_check_box = Qt.QCheckBox("Enable Antenna Calibration")
        self._ant_cal_enable_choices = {True: 0, False: 1}
        self._ant_cal_enable_choices_inv = dict((v,k) for k,v in self._ant_cal_enable_choices.iteritems())
        self._ant_cal_enable_callback = lambda i: Qt.QMetaObject.invokeMethod(_ant_cal_enable_check_box, "setChecked", Qt.Q_ARG("bool", self._ant_cal_enable_choices_inv[i]))
        self._ant_cal_enable_callback(self.ant_cal_enable)
        _ant_cal_enable_check_box.stateChanged.connect(lambda i: self.set_ant_cal_enable(self._ant_cal_enable_choices[bool(i)]))
        self.top_grid_layout.addWidget(_ant_cal_enable_check_box, 1,4)
        self.wifius_gen_music_spectrum_vcvf_0 = wifius.gen_music_spectrum_vcvf(3, 1, -90, 90, 1, 0.5, 4096)
        self.wifius_antenna_array_calibration_cf_0 = wifius.antenna_array_calibration_cf(90, 0.5, 3, snapshots)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(("addr0=192.168.40.2,addr1=192.168.50.2,addr2=192.168.60.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(3),
        	),
        )
        self.uhd_usrp_source_0_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0_0.set_time_source("external", 0)
        self.uhd_usrp_source_0_0.set_clock_source("external", 1)
        self.uhd_usrp_source_0_0.set_time_source("external", 1)
        self.uhd_usrp_source_0_0.set_clock_source("mimo", 2)
        self.uhd_usrp_source_0_0.set_time_source("mimo", 2)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 0)
        self.uhd_usrp_source_0_0.set_antenna("RX2", 0)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 1)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 1)
        self.uhd_usrp_source_0_0.set_antenna("RX2", 1)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 2)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 2)
        self.uhd_usrp_source_0_0.set_antenna("RX2", 2)
        self.sync_tx_hier_0_0 = sync_tx_hier(
            addr0="addr=192.168.30.2",
            cal_freq=10e3,
            center_freq=center_freq,
            gain_tx2=20,
            samp_rate=samp_rate,
            tone_type='Real',
        )
        self.sync_tx_hier2_0 = sync_tx_hier2(
            addr0="addr=192.168.20.2",
            cal_freq=10e3,
            center_freq=2.4e9,
            gain_tx2=20,
            samp_rate=samp_rate,
            tone_type='Real',
        )
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            180,
            -90,
            1.0,
            "Offset",
            "dB",
            "MuSIC Spectrum",
            1 # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.10)
        self.qtgui_vector_sink_f_0.set_y_axis(-140, 10)
        self.qtgui_vector_sink_f_0.enable_autoscale(True)
        self.qtgui_vector_sink_f_0.enable_grid(True)
        self.qtgui_vector_sink_f_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0.set_ref_level(0)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_vector_sink_f_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_vector_sink_f_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	300, #size
        	samp_rate, #samp_rate
        	"", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(True)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["RX1", "RX2", "", "", "",
                  "", "", "", "", ""]
        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(3):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_short,
            0,
            qtgui.NUM_GRAPH_HORIZ,
            1
        )
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        units = ["", "", "", "", "",
                 "", "", "", "", ""]
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])
        
        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, snapshots)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, snapshots)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, snapshots)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*1)
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vcc((numpy.exp(-1j*phase_c2*pi/180), ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((numpy.exp(-1j*phase_c1*pi/180), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((numpy.exp(-1j*phase_c0*pi/180), ))
        self.blocks_message_strobe_0_3 = blocks.message_strobe(pmt.from_double(ant_cal_enable), 1000)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_0), 1000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_0_0), 1000)
        self.blocks_complex_to_real_0_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_argmax_xx_0 = blocks.argmax_fs(180)
        self.blocks_add_const_vxx_0 = blocks.add_const_vss((-90, ))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.sync_tx_hier2_0, 'Trigger'))    
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.sync_tx_hier_0_0, 'Trigger'))    
        self.msg_connect((self.blocks_message_strobe_0_3, 'strobe'), (self.wifius_antenna_array_calibration_cf_0, 'enable_hold'))    
        self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_0, 0))    
        self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_complex_to_real_0_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.blocks_complex_to_real_0_0_0, 0), (self.qtgui_time_sink_x_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wifius_antenna_array_calibration_cf_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_real_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_stream_to_vector_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wifius_antenna_array_calibration_cf_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_complex_to_real_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_stream_to_vector_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.wifius_antenna_array_calibration_cf_0, 2))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 2))    
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 3))    
        self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 4))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 2), (self.blocks_multiply_const_vxx_0_0_0, 0))    
        self.connect((self.wifius_antenna_array_calibration_cf_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 0))    
        self.connect((self.wifius_antenna_array_calibration_cf_0, 1), (self.wifius_gen_music_spectrum_vcvf_0, 1))    
        self.connect((self.wifius_gen_music_spectrum_vcvf_0, 0), (self.blocks_argmax_xx_0, 0))    
        self.connect((self.wifius_gen_music_spectrum_vcvf_0, 0), (self.qtgui_vector_sink_f_0, 0))    
コード例 #9
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))
コード例 #10
0
    def __init__(self, address="addr=192.168.10.3"):
        gr.top_block.__init__(self, "Nbfm Transmit")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Nbfm Transmit")
        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", "nbfm_transmit")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.address = address

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 400e3
        self.gain = gain = 50
        self.audio_rate = audio_rate = 48e3

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join((address, "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_clock_rate(200e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(94e6, 0)
        self.uhd_usrp_sink_0.set_gain(50, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(75e3, 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=529,
                decimation=441,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_sink_x_0 = qtgui.sink_c(
        	1024, #fftsize
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	94e6, #fc
        	samp_rate, #bw
        	"", #name
        	True, #plotfreq
        	True, #plotwaterfall
        	True, #plottime
        	True, #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0/10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)
        
        self.qtgui_sink_x_0.enable_rf_freq(False)
        
        
          
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_f(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_1.disable_legend()
        
        if "float" == "float" or "float" == "msg_float":
          self.qtgui_freq_sink_x_1.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((.3, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, ))
        self.audio_source = blocks.wavfile_source("/home/ettus/Música/bensound-photoalbum.wav", True)
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=44000,
        	quad_rate=44000,
        	tau=75e-6,
        	max_dev=5e3,
                )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.audio_source, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.audio_source, 0), (self.qtgui_freq_sink_x_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_sink_x_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_nbfm_tx_0, 0))    
コード例 #11
0
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22

        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, eb, 5 * sps * nfilts)

        self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500,
            882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952
        ]
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.vector = vector = [int(random.random() * 4) for i in range(49600)]
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 39
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50
        self.samp_rate = samp_rate = samp_rate_array_MCR[2]

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts)

        self.pld_enc = pld_enc = map(
            (lambda a: fec.cc_encoder_make(440, k, rate,
                                           (polys), 0, fec.CC_TERMINATED, True)
             ), range(0, 8))

        self.pld_dec = pld_dec = map((lambda a: fec.cc_decoder.make(
            440, k, rate, (polys), 0, -1, fec.CC_TERMINATED, True)),
                                     range(0, 4))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 39, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 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._variable_qtgui_range_0_range = Range(0, 90, 1, 50, 200)
        self._variable_qtgui_range_0_win = RangeWidget(
            self._variable_qtgui_range_0_range,
            self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_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.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("serial=F5EAC0", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAE1", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self.qtgui_time_sink_x_2_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "After CAC",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0.set_y_axis(0, 1.5)

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

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

        if not True:
            self.qtgui_time_sink_x_2_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_2_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_win, 2, 4,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_2 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "Defore CAC",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2.set_update_time(0.10)
        self.qtgui_time_sink_x_2.set_y_axis(0, 1.5)

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

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

        if not True:
            self.qtgui_time_sink_x_2.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_2.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win, 2, 3, 1,
                                       1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 4,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_0_1.disable_legend()

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

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

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 5,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Tx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 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.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "RX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_1.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "TX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 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.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay)

        self.fec_extended_encoder_0 = fec.extended_encoder(
            encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat)
        self.fec_extended_decoder_0_0_1_0_1_0 = fec.extended_decoder(
            decoder_obj_list=pld_dec,
            threading='capillary',
            ann=None,
            puncpat=puncpat,
            integration_period=10000)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 400.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code()))
        self.digital_map_bb_0_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(4)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 200.0, pld_const.arity(), False)
        self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(
            digital.packet_utils.default_access_code, 1, 'packet_len')
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            pld_const)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_const.points()), 1)
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True,
                                                                   1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_b([0], True, 1,
                                                               [])
        self.blocks_vector_insert_x_0 = blocks.vector_insert_b((vector),
                                                               496000000, 0)
        self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, 992, "packet_len")
        self.blocks_stream_mux_0_1_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (96, 896))
        self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1,
                                                       (892, 4))
        self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char * 1,
                                                     (440, 2))
        self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb(
            8, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb(
            1, 2, "packet_len", False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            2, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_keep_m_in_n_0_1_1_0 = blocks.keep_m_in_n(
            gr.sizeof_char, 440, 442, 0)
        self.blocks_keep_m_in_n_0_0_2_0 = blocks.keep_m_in_n(
            gr.sizeof_char, 892, 896, 0)
        self.blocks_file_source_0_0_1_0_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/andre/Downloads/lion-sample.mts', False)
        self.blocks_file_source_0_0_1_0_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/andre/Desktop/transmitido/depois.mts',
            False)
        self.blocks_file_sink_0_0_0_0_0.set_unbuffered(False)
        self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.acode_1104 = blocks.vector_source_b([
            0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1,
            0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x0
        ], True, 1, [])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_2, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_2_0, 0))
        self.connect((self.blocks_char_to_float_0_2_0_0, 0),
                     (self.fec_extended_decoder_0_0_1_0_1_0, 0))
        self.connect((self.blocks_char_to_float_1_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_file_source_0_0_1_0_0, 0),
                     (self.blocks_char_to_float_1_0_0, 0))
        self.connect((self.blocks_file_source_0_0_1_0_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_1, 0))
        self.connect((self.blocks_keep_m_in_n_0_0_2_0, 0),
                     (self.digital_map_bb_0_0_0_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_const_sink_x_0_0_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0),
                     (self.blocks_vector_insert_x_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.blocks_stream_mux_0, 0))
        self.connect((self.blocks_stream_mux_0, 0),
                     (self.fec_extended_encoder_0, 0))
        self.connect((self.blocks_stream_mux_0_0, 0),
                     (self.blocks_stream_mux_0_1_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_0, 0))
        self.connect((self.blocks_vector_insert_x_0, 0),
                     (self.digital_map_bb_1_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_mux_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_stream_mux_0_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_keep_m_in_n_0_0_2_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_map_bb_0_0_0_0_0, 0),
                     (self.blocks_char_to_float_0_2_0_0, 0))
        self.connect((self.digital_map_bb_1_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.fec_extended_decoder_0_0_1_0_1_0, 0),
                     (self.blocks_keep_m_in_n_0_1_1_0, 0))
        self.connect((self.fec_extended_encoder_0, 0),
                     (self.blocks_stream_mux_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
コード例 #12
0
ファイル: radio.py プロジェクト: bistromath/gr-ais
  def _setup_source(self, options):
    if options.source == "uhd":
      #UHD source by default
      from gnuradio import uhd
      src = uhd.single_usrp_source(options.args, uhd.io_type_t.COMPLEX_FLOAT32, 1)

      if(options.subdev):
        src.set_subdev_spec(options.subdev, 0)

      if not src.set_center_freq(162.0e6 * (1 + options.error/1.e6)):
        print "Failed to set initial frequency"
      else:
        print "Tuned to %.3fMHz" % (src.get_center_freq() / 1.e6)

      #check for GPSDO
      #if you have a GPSDO, UHD will automatically set the timestamp to UTC time
      #as well as automatically set the clock to lock to GPSDO.
      if src.get_time_source(0) != 'gpsdo':
        src.set_time_now(uhd.time_spec(0.0))

      if options.antenna is not None:
        src.set_antenna(options.antenna)

      src.set_samp_rate(options.rate)

      if options.gain is None: #set to halfway
        g = src.get_gain_range()
        options.gain = (g.start()+g.stop()) / 2.0

      print "Setting gain to %i" % options.gain
      src.set_gain(options.gain)
      print "Gain is %i" % src.get_gain()

    #TODO: detect if you're using an RTLSDR or Jawbreaker
    #and set up accordingly.
    elif options.source == "osmocom": #RTLSDR dongle or HackRF Jawbreaker
        import osmosdr
        src = osmosdr.source(options.args)
        src.set_sample_rate(options.rate)
        src.get_samp_rate = src.get_sample_rate #alias for UHD compatibility
        if not src.set_center_freq(162.0e6 * (1 + options.error/1.e6)):
            print "Failed to set initial frequency"
        else:
            print "Tuned to %.3fMHz" % (src.get_center_freq() / 1.e6)

        if options.gain is None:
            options.gain = 34
        src.set_gain(options.gain)
        print "Gain is %i" % src.get_gain()

    else:
      #semantically detect whether it's ip.ip.ip.ip:port or filename
      self._rate = options.rate
      if ':' in options.source:
        try:
          ip, port = re.search("(.*)\:(\d{1,5})", options.source).groups()
        except:
          raise Exception("Please input UDP source e.g. 192.168.10.1:12345")
        src = blocks.udp_source(gr.sizeof_gr_complex, ip, int(port))
        print "Using UDP source %s:%s" % (ip, port)
      else:
        src = blocks.file_source(gr.sizeof_gr_complex, options.source)
        print "Using file source %s" % options.source

    return src
コード例 #13
0
ファイル: radio.py プロジェクト: darkstar007/gr-air-modes
  def _setup_source(self, options):
    if options.source == "uhd":
      #UHD source by default
      from gnuradio import uhd
      self._u = uhd.single_usrp_source(options.args, uhd.io_type_t.COMPLEX_FLOAT32, 1)

      if(options.subdev):
        self._u.set_subdev_spec(options.subdev, 0)

      if not self._u.set_center_freq(options.freq):
        print "Failed to set initial frequency"

      #check for GPSDO
      #if you have a GPSDO, UHD will automatically set the timestamp to UTC time
      #as well as automatically set the clock to lock to GPSDO.
      if self._u.get_time_source(0) != 'gpsdo':
        self._u.set_time_now(uhd.time_spec(0.0))

      if options.antenna is not None:
        self._u.set_antenna(options.antenna)

      self._u.set_samp_rate(options.rate)
      options.rate = int(self._u.get_samp_rate()) #retrieve actual

      if options.gain is None: #set to halfway
        g = self._u.get_gain_range()
        options.gain = (g.start()+g.stop()) / 2.0

      print "Setting gain to %i" % options.gain
      self._u.set_gain(options.gain)
      print "Gain is %i" % self._u.get_gain()

    #TODO: detect if you're using an RTLSDR or Jawbreaker
    #and set up accordingly.
    elif options.source == "osmocom": #RTLSDR dongle or HackRF Jawbreaker
        import osmosdr
        self._u = osmosdr.source(options.args)
#        self._u.set_sample_rate(3.2e6) #fixed for RTL dongles
        self._u.set_sample_rate(options.rate)
        if not self._u.set_center_freq(options.freq):
            print "Failed to set initial frequency"

#        self._u.set_gain_mode(0) #manual gain mode
        if options.gain is None:
            options.gain = 34
        self._u.set_gain(options.gain)
        print "Gain is %i" % self._u.get_gain()

        #Note: this should only come into play if using an RTLSDR.
#        lpfiltcoeffs = gr.firdes.low_pass(1, 5*3.2e6, 1.6e6, 300e3)
#        self._resample = filter.rational_resampler_ccf(interpolation=5, decimation=4, taps=lpfiltcoeffs)

    else:
      #semantically detect whether it's ip.ip.ip.ip:port or filename
      if ':' in options.source:
        try:
          ip, port = re.search("(.*)\:(\d{1,5})", options.source).groups()
        except:
          raise Exception("Please input UDP source e.g. 192.168.10.1:12345")
        self._u = blocks.udp_source(gr.sizeof_gr_complex, ip, int(port))
        print "Using UDP source %s:%s" % (ip, port)
      else:
        #self._u = blocks.file_source(gr.sizeof_gr_complex, options.source)
        self._u = ReadByteFile(options)
        print "Using file source %s" % options.source

    print "Rate is %i" % (options.rate,)
コード例 #14
0
ファイル: uhd_modes.py プロジェクト: asirinelli/gr-air-modes
  def __init__(self, options, args, queue):
    gr.top_block.__init__(self)

    self.options = options
    self.args = args
    rate = int(options.rate)
    use_resampler = False

    if options.filename is None and options.udp is None and not options.rtlsdr:
      #UHD source by default
      from gnuradio import uhd
      self.u = uhd.single_usrp_source("", uhd.io_type_t.COMPLEX_FLOAT32, 1)
      time_spec = uhd.time_spec(0.0)
      self.u.set_time_now(time_spec)

      #if(options.rx_subdev_spec is None):
      #  options.rx_subdev_spec = ""
      #self.u.set_subdev_spec(options.rx_subdev_spec)
      if not options.antenna is None:
        self.u.set_antenna(options.antenna)

      self.u.set_samp_rate(rate)
      rate = int(self.u.get_samp_rate()) #retrieve actual

      if options.gain is None: #set to halfway
        g = self.u.get_gain_range()
        options.gain = (g.start()+g.stop()) / 2.0

      if not(self.tune(options.freq)):
        print "Failed to set initial frequency"

      print "Setting gain to %i" % options.gain
      self.u.set_gain(options.gain)
      print "Gain is %i" % self.u.get_gain()
      
    elif options.rtlsdr: #RTLSDR dongle
        import osmosdr
        self.u = osmosdr.source_c()
        self.u.set_sample_rate(2.4e6) #fixed for RTL dongles
        if not self.u.set_center_freq(options.freq):
            print "Failed to set initial frequency"

        self.u.set_gain_mode(0) #manual gain mode
        if options.gain is None:
            options.gain = 49
            
        self.u.set_gain(options.gain)
        print "Gain is %i" % self.u.get_gain()

        use_resampler = True
                
    else:
      if options.filename is not None:
        self.u = gr.file_source(gr.sizeof_gr_complex, options.filename)
      elif options.udp is not None:
        self.u = gr.udp_source(gr.sizeof_gr_complex, "localhost", options.udp)
      else:
        raise Exception("No valid source selected")
        

    print "Rate is %i" % (rate,)

    pass_all = 0
    if options.output_all :
      pass_all = 1

    self.demod = gr.complex_to_mag()
    self.avg = gr.moving_average_ff(100, 1.0/100, 400)
    
    self.preamble = air_modes.modes_preamble(rate, options.threshold)
    #self.framer = air_modes.modes_framer(rate)
    self.slicer = air_modes.modes_slicer(rate, queue)

    if use_resampler:
        self.lpfiltcoeffs = gr.firdes.low_pass(1, 5*2.4e6, 1.2e6, 300e3)
        self.resample = blks2.rational_resampler_ccf(interpolation=5, decimation=3, taps=self.lpfiltcoeffs)
        self.connect(self.u, self.resample, self.demod)
    else:
        self.connect(self.u, self.demod)

    self.connect(self.demod, self.avg)
    self.connect(self.demod, (self.preamble, 0))
    self.connect(self.avg, (self.preamble, 1))
    self.connect((self.preamble, 0), (self.slicer, 0))
コード例 #15
0
ファイル: ampm_cli.py プロジェクト: jordens/xcorr
    def __init__(self, decim=50, decim_df=.2, decim_f=.4, device_address="type=b200", device_arguments="master_clock_rate=30.72e6", df_ref=0, df_test=10e3, f_sample=960e3*4, f_sig=6e9, g_ref=0, g_sig=0, g_test=49, n_samples=1<<24, name="test", pass_tags=False, port_base=6880, f_dsp=0):
        gr.top_block.__init__(self, "Ampm Cli")

        ##################################################
        # Parameters
        ##################################################
        self.decim = decim
        self.decim_df = decim_df
        self.decim_f = decim_f
        self.device_address = device_address
        self.device_arguments = device_arguments
        self.df_ref = df_ref
        self.df_test = df_test
        self.f_sample = f_sample
        self.f_sig = f_sig
        self.g_ref = g_ref
        self.g_sig = g_sig
        self.g_test = g_test
        self.n_samples = n_samples
        self.name = name
        self.pass_tags = pass_tags
        self.port_base = port_base
        self.f_dsp = f_dsp

        ##################################################
        # Variables
        ##################################################
        self.info = info = {"name":name, "f_sig":f_sig, "df_ref":df_ref, "f_sample":f_sample, "decim":decim}
        self.filename = filename = "{:s}_f0{:.5g}_df{:.5g}_fs{:.5g}_d{:.5g}".format(name, f_sig/1e6, df_ref, f_sample/1e6, decim)

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0_2_0 = zeromq.sub_source(gr.sizeof_float, decim**0, "tcp://localhost:{}".format(port_base + 9), 100, pass_tags)
        self.zeromq_sub_source_0_2 = zeromq.sub_source(gr.sizeof_gr_complex, decim**0, "tcp://localhost:{}".format(port_base + 0), 100, pass_tags)
        self.zeromq_sub_source_0_1 = zeromq.sub_source(gr.sizeof_gr_complex, decim**1, "tcp://localhost:6881", 100, pass_tags)
        self.zeromq_sub_source_0_0 = zeromq.sub_source(gr.sizeof_gr_complex, decim**3, "tcp://localhost:6883", 100, pass_tags)
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, decim**2, "tcp://localhost:6882", 100, pass_tags)
        self.zeromq_pub_sink_0_1_2 = zeromq.pub_sink(gr.sizeof_float, decim**0, "tcp://*:{}".format(port_base + 9), 100, pass_tags)
        self.zeromq_pub_sink_0_1_1 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**1, "tcp://*:{}".format(port_base + 1), 100, pass_tags)
        self.zeromq_pub_sink_0_1_0_0 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**3, "tcp://*:{}".format(port_base + 3), 100, pass_tags)
        self.zeromq_pub_sink_0_1_0 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**2, "tcp://*:{}".format(port_base + 2), 100, pass_tags)
        self.zeromq_pub_sink_0_1 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**0, "tcp://*:{}".format(port_base + 0), 100, pass_tags)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join((device_address, device_arguments)),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(2),
        	),
        )
        self.uhd_usrp_source_0_0.set_subdev_spec("A:A A:B", 0)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0.set_samp_rate(f_sample)
        self.uhd_usrp_source_0_0.set_center_freq(uhd.tune_request(target_freq=f_sig , dsp_freq=f_dsp, rf_freq_policy=uhd.tune_request.POLICY_AUTO, dsp_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0_0.set_gain(g_sig, 0)
        self.uhd_usrp_source_0_0.set_bandwidth(30.72e6, 0)
        self.uhd_usrp_source_0_0.set_center_freq(uhd.tune_request(target_freq=f_sig + df_ref, dsp_freq=f_dsp, rf_freq_policy=uhd.tune_request.POLICY_AUTO, dsp_freq_policy=uhd.tune_request.POLICY_MANUAL), 1)
        self.uhd_usrp_source_0_0.set_gain(g_ref, 1)
        self.uhd_usrp_source_0_0.set_bandwidth(30.72e6, 1)
        self.blocks_stream_to_vector_0_1_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**3)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**2)
        self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector(gr.sizeof_float*1, decim**0)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**0)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**1)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*decim**3, n_samples/decim**3)
        self.blocks_head_0_1 = blocks.head(gr.sizeof_gr_complex*decim**1, n_samples/decim**1)
        self.blocks_head_0_0 = blocks.head(gr.sizeof_gr_complex*decim**3, n_samples/decim**3)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*decim**2, n_samples/decim**2)
        self.blocks_file_meta_sink_0_3_0 = blocks.file_meta_sink(gr.sizeof_float*decim**0, "{}_w.bin".format(filename), f_sample, decim**3, blocks.GR_FILE_FLOAT, False, 1<<20, "", True)
        self.blocks_file_meta_sink_0_3_0.set_unbuffered(False)
        self.blocks_file_meta_sink_0_3 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**0, "{}_0.bin".format(filename), f_sample, decim**3, blocks.GR_FILE_FLOAT, True, 1<<20, "", True)
        self.blocks_file_meta_sink_0_3.set_unbuffered(False)
        self.blocks_file_meta_sink_0_1 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**1, "{}_1.bin".format(filename), f_sample, decim**2, blocks.GR_FILE_FLOAT, True, 1<<20, "", True)
        self.blocks_file_meta_sink_0_1.set_unbuffered(False)
        self.blocks_file_meta_sink_0_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**3, "{}_3.bin".format(filename), f_sample, decim**0, blocks.GR_FILE_FLOAT, True, 1<<20, "", True)
        self.blocks_file_meta_sink_0_0.set_unbuffered(False)
        self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**2, "{}_2.bin".format(filename), f_sample, decim**1, blocks.GR_FILE_FLOAT, True, 1<<20, "", True)
        self.blocks_file_meta_sink_0.set_unbuffered(False)
        self.blocks_ctrlport_probe2_c_0_1 = blocks.ctrlport_probe2_c("d0", "diff0", 1024, gr.DISPTIME)
        self.blocks_ctrlport_probe2_c_0_0 = blocks.ctrlport_probe2_c("b", "input b", 1024, gr.DISPTIME)
        self.blocks_ctrlport_probe2_c_0 = blocks.ctrlport_probe2_c("a", "input a", 1024, gr.DISPTIME)
        self.blocks_ctrlport_monitor_0 = not True or monitor()
        self.Ampm_0 = Ampm(
            decim=decim,
            decim_df=decim_df,
            decim_f=decim_f,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.Ampm_0, 0), (self.blocks_ctrlport_probe2_c_0_1, 0))    
        self.connect((self.Ampm_0, 2), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.Ampm_0, 3), (self.blocks_stream_to_vector_0_0, 0))    
        self.connect((self.Ampm_0, 4), (self.blocks_stream_to_vector_0_0_0, 0))    
        self.connect((self.Ampm_0, 1), (self.blocks_stream_to_vector_0_1, 0))    
        self.connect((self.Ampm_0, 0), (self.blocks_stream_to_vector_0_1_0, 0))    
        self.connect((self.blocks_head_0, 0), (self.blocks_file_meta_sink_0, 0))    
        self.connect((self.blocks_head_0_0, 0), (self.blocks_file_meta_sink_0_0, 0))    
        self.connect((self.blocks_head_0_1, 0), (self.blocks_file_meta_sink_0_1, 0))    
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_head_0_0, 0))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.zeromq_pub_sink_0_1_1, 0))    
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.zeromq_pub_sink_0_1, 0))    
        self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.zeromq_pub_sink_0_1_2, 0))    
        self.connect((self.blocks_stream_to_vector_0_1, 0), (self.zeromq_pub_sink_0_1_0, 0))    
        self.connect((self.blocks_stream_to_vector_0_1_0, 0), (self.zeromq_pub_sink_0_1_0_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.Ampm_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.Ampm_0, 1))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_ctrlport_probe2_c_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_ctrlport_probe2_c_0_0, 0))    
        self.connect((self.zeromq_sub_source_0, 0), (self.blocks_head_0, 0))    
        self.connect((self.zeromq_sub_source_0_0, 0), (self.blocks_skiphead_0, 0))    
        self.connect((self.zeromq_sub_source_0_1, 0), (self.blocks_head_0_1, 0))    
        self.connect((self.zeromq_sub_source_0_2, 0), (self.blocks_file_meta_sink_0_3, 0))    
        self.connect((self.zeromq_sub_source_0_2_0, 0), (self.blocks_file_meta_sink_0_3_0, 0))    
コード例 #16
0
ファイル: top_block.py プロジェクト: reysam93/GNURadio
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.pdu_length = pdu_length = 500
        self.lo_offset = lo_offset = 0
        self.gain = gain = 0.75
        self.freq = freq = 5890000000
        self.encoding = encoding = [0,0,0,0,0]
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.frequencyAdaptiveOFDM_mac_and_parse_0 = frequencyAdaptiveOFDM.mac_and_parse(([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), False, True, '/tmp/tx_packets.csv', '/tmp/rx_packets.csv')
        self._samp_rate_options = [5e6, 10e6, 20e6]
        self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self._pdu_length_range = Range(0, 1500, 1, 500, 200)
        self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, "pdu_length", "counter_slider", int)
        self.top_layout.addWidget(self._pdu_length_win)
        self._lo_offset_options = (0, 6e6, 11e6, )
        self._lo_offset_labels = (str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset"+": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self._gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self._freq_options = [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0]
        self._freq_labels = ['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq"+": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels: self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)

        def _encoding_probe():
            while True:
                val = self.frequencyAdaptiveOFDM_mac_and_parse_0.get_encoding()
                try:
                    self.set_encoding(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1000))
        _encoding_thread = threading.Thread(target=_encoding_probe)
        _encoding_thread.daemon = True
        _encoding_thread.start()

        self._chan_est_options = 0, 1, 3, 2
        self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"]
        self._chan_est_group_box = Qt.QGroupBox("chan_est")
        self._chan_est_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._chan_est_button_group = variable_chooser_button_group()
        self._chan_est_group_box.setLayout(self._chan_est_box)
        for i, label in enumerate(self._chan_est_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._chan_est_box.addWidget(radio_button)
        	self._chan_est_button_group.addButton(radio_button, i)
        self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i)))
        self._chan_est_callback(self.chan_est)
        self._chan_est_button_group.buttonClicked[int].connect(
        	lambda i: self.set_chan_est(self._chan_est_options[i]))
        self.top_layout.addWidget(self._chan_est_group_box)
        self.wifi_freq_adap_phy_hier_0 = wifi_freq_adap_phy_hier(
            bandwidth=10e6,
            chan_est=0,
            encoding=encoding,
            frequency=5.89e9,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(('', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(('', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	'packet_len',
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_normalized_gain(gain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	300000, #samp_rate
        	"Data Received", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_NONE,
            1
        )
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

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

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	48*10, #size
        	"", #name
        	4 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0.disable_legend()

        labels = ['RB1', 'RB2', 'RB3', 'RB4', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "yellow", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(4):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.frequencyAdaptiveOFDM_write_frame_data_0 = frequencyAdaptiveOFDM.write_frame_data('/tmp/snr.csv', '/tmp/encoding.csv', '/tmp/wifi_frame_delay.csv', True)
        self.frequencyAdaptiveOFDM_rb_const_demux_stream_0 = frequencyAdaptiveOFDM.rb_const_demux_stream('packet_len')
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_vector_source_x_0 = blocks.vector_source_b(range(100), True, 1, [])
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, pdu_length, 'packet_len')
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False)
        self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, 'packet_len')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.adaptiveOFDM_stream_spacer_0 = adaptiveOFDM.stream_spacer(blocks.byte_t, 500)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app in'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app in'))
        self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus'))
        self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'frame data'), (self.frequencyAdaptiveOFDM_write_frame_data_0, 'frame data'))
        self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy out'), (self.wifi_freq_adap_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'mac_out'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy in'))
        self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'carrier'), (self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 'symbols_in'))
        self.connect((self.adaptiveOFDM_stream_spacer_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.adaptiveOFDM_stream_spacer_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 1), (self.qtgui_const_sink_x_0, 1))
        self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 2), (self.qtgui_const_sink_x_0, 2))
        self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 3), (self.qtgui_const_sink_x_0, 3))
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_freq_adap_phy_hier_0, 0))
        self.connect((self.wifi_freq_adap_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))
コード例 #17
0
ファイル: test_uci.py プロジェクト: teoyenmao/usrp_project
def main():

    global n_rcvd, n_right, v_frame, mean_delta, next_tx_ts, stop_rx_ts, ps_end_ts, alloc_index, vf_index,\
        listen_only_to

    n_rcvd = 0
    n_right = 0
    mean_delta = 0
    next_tx_ts = 0
    stop_rx_ts = 0
    ps_end_ts = 0
    alloc_index = -1
    vf_index = -1
    listen_only_to = []
    wrong_pktno = 0xFF00
    v_frame = ''
    vf_len = 8

    ps_model = PerfectScheme(PacketType.PS_BROADCAST.index, PacketType.PS_PKT.index, NODE_SLOT_TIME)
    vfs_model = VirtualFrameScheme(PacketType.VFS_BROADCAST.index, PacketType.VFS_PKT.index, NODE_SLOT_TIME)

    def send_beacon_pkt(my_tb, pkt_size, pkt_no):        # BS only
        # payload = prefix + now + beacon + dummy

        payload_prefix = struct.pack('!H', pkt_no & 0xffff)
        beacon = struct.pack('!H', PacketType.BEACON.index & 0xffff)
        data_size = len(payload_prefix) + TIMESTAMP_LEN + len(beacon)
        dummy = (pkt_size - data_size) * chr(pkt_no & 0xff)
        now_timestamp = my_tb.sink.get_time_now().get_real_secs()
        now_timestamp_str = '{:.3f}'.format(now_timestamp)
        payload = payload_prefix + now_timestamp_str + beacon + dummy
        my_tb.txpath.send_pkt(payload)
        logger.info("{} broadcast BEACON - {}".format(str(datetime.fromtimestamp(now_timestamp)), pkt_no))

    # Deprecated
    # def send_resp_beacon_pkt(my_tb, pkt_size, pkt_no):     # Node only
    #     # payload = prefix + now + respond_beacon + node_id + dummy
    #
    #     payload_prefix = struct.pack('!H', pkt_no & 0xffff)
    #     respond_beacon = struct.pack('!H', PacketType.RESPOND_BEACON.index & 0xffff)
    #     data_size = len(payload_prefix) + TIMESTAMP_LEN + len(respond_beacon) + NODE_ID_LEN
    #     dummy = (pkt_size - data_size) * chr(pkt_no & 0xff)
    #     now_timestamp = my_tb.sink.get_time_now().get_real_secs()
    #     now_timestamp_str = '{:.3f}'.format(now_timestamp)
    #     payload = payload_prefix + now_timestamp_str + respond_beacon + NODE_ID + dummy
    #     my_tb.txpath.send_pkt(payload)
    #     logger.info("{} send RESPOND_BEACON - {}".format(str(datetime.fromtimestamp(now_timestamp)), pkt_no))
    #
    #     # TODO: how to track rtt?
    #     # Keep rtt_list size limit
    #     rtt_list.append(now_timestamp)
    #     if len(rtt_list) > MAX_RTT_AMT:
    #         rtt_list.pop(0)

    def do_every_beacon(interval, _send_pkt_func, my_tb, pkt_size, max_pkt_amt, iteration=1):
        # For other functions to check these variables
        global my_thread, my_iteration
        my_iteration = iteration

        if iteration < max_pkt_amt:
            # my_thread = threading.Timer(interval, do_every_beacon,
            #                             [interval, _send_pkt_func, my_tb, pkt_amt, 0
            #                                 if iteration == 0 else iteration + 1])
            my_thread = threading.Timer(interval, do_every_beacon,
                                        [interval, _send_pkt_func, my_tb, pkt_size, max_pkt_amt,
                                         max_pkt_amt if iteration >= max_pkt_amt else iteration + 1])
            my_thread.start()
        # execute func
        _send_pkt_func(my_tb, pkt_size, iteration)

    def do_every_protocol_bs(interval, _send_pkt_func, my_tb, pkt_size, node_amt, max_pkt_amt, iteration=1):
        # For other functions to check these variables
        global my_thread, my_iteration
        my_iteration = iteration

        if iteration < max_pkt_amt:
            my_thread = threading.Timer(interval, do_every_protocol_bs,
                                        [interval, _send_pkt_func, my_tb, pkt_size, node_amt, max_pkt_amt,
                                         max_pkt_amt if iteration >= max_pkt_amt else iteration + 1])
            my_thread.start()
        # execute func
        _send_pkt_func(my_tb, pkt_size, node_amt, iteration)

    def do_every_protocol_node(interval, _send_pkt_func, node_id, my_tb, pkt_size, node_data, max_pkt_amt, iteration=1):
        # For other functions to check these variables
        global my_thread, my_iteration
        my_iteration = iteration

        if iteration < max_pkt_amt:
            my_thread = threading.Timer(interval, do_every_protocol_node,
                                        [interval, _send_pkt_func, node_id, my_tb, pkt_size, node_data, max_pkt_amt,
                                         max_pkt_amt if iteration >= max_pkt_amt else iteration + 1])
            my_thread.start()
        # execute func
        _send_pkt_func(node_id, my_tb, pkt_size, node_data, iteration)

    def rx_bs_callback(ok, payload):    # For BS
        global n_rcvd, n_right, mean_delta, next_tx_ts, stop_rx_ts, nodes_sync_delta, listen_only_to

        n_rcvd += 1

        (pktno,) = struct.unpack('!H', payload[0:2])
        # Filter out incorrect pkt
        if pktno >= wrong_pktno:
            logger.warning("wrong pktno {}. Drop pkt!".format(pktno))
            return

        try:
            pkt_timestamp_str = payload[2:2+TIMESTAMP_LEN]
            pkt_timestamp = float(pkt_timestamp_str)
        except:
            logger.warning("Timestamp {} is not a float. Drop pkt!".format(pkt_timestamp_str))
            return

        now_timestamp = rx_tb.source.get_time_now().get_real_secs()
        # now_timestamp_str = '{:.3f}'.format(now_timestamp)
        delta = now_timestamp - pkt_timestamp   # +ve: Node earlier; -ve: BS earlier
        if not -5 < delta < 5:
            logger.warning("Delay out-of-range: {}, timestamp {}. Drop pkt!".format(delta, pkt_timestamp_str))
            return

        (pkt_type,) = struct.unpack('!H', payload[2+TIMESTAMP_LEN:2+TIMESTAMP_LEN+2])
        # if pkt_type not in [PacketType.RESPOND_BEACON.index, PacketType.PS_PKT.index]:
        if pkt_type not in [PacketType.PS_PKT.index, PacketType.VFS_PKT.index]:
            logger.warning("Invalid pkt_type {}. Drop pkt!".format(pkt_type))
            return
        if listen_only_to and pkt_type not in listen_only_to:
            str_listen_only_to = [PacketType[x].key for x in listen_only_to]
            logger.warning("Interest only in pkt_type {}, not {}. Drop pkt!".format(
                str_listen_only_to, PacketType[pkt_type].key))
            return

        # Deprecated
        # if pkt_type == PacketType.RESPOND_BEACON.index:
        #     node_id = payload[2+TIMESTAMP_LEN+2:2+TIMESTAMP_LEN+2+NODE_ID_LEN]
        #     if nodes_sync_delta.get(node_id) is None:
        #         nodes_sync_delta[node_id] = []
        #     nodes_sync_delta[node_id].append(delta)
        #     # Keep nodes_sync_delta in size limit
        #     if len(nodes_sync_delta[node_id]) > MAX_DELTA_AMT:
        #         nodes_sync_delta[node_id].pop(0)
        #     mean_delta = numpy.mean(nodes_sync_delta[node_id])
        #
        #     next_tx_ts = now_timestamp + 0.5 - COMMAND_DELAY
        #
        #     logger.info("{} BS recv RESPOND_BEACON from node {}. Node time: {}, Avg delay: {}".format(
        #         str(datetime.fromtimestamp(now_timestamp)), node_id, str(datetime.fromtimestamp(pkt_timestamp)),
        #         mean_delta))
        #     # logger.debug("Node {} len {} {}".format(node_id, len(nodes_sync_delta[node_id]), nodes_sync_delta[node_id]))
        #     # logger.debug("Node {}: {}".format(node_id, nodes_sync_delta[node_id]))
        #     return

        if pkt_type == PacketType.PS_PKT.index:
            for i, tpl in enumerate(ps_model.nodes_expect_time):
                node_id, begin_at, end_at = tpl
                if begin_at <= now_timestamp <= end_at:
                    logger.info("{} ({}) [Slot {}: Node {} Session] BS recv PS_PKT {}, data: {}".format(
                        str(datetime.fromtimestamp(now_timestamp)), now_timestamp, i, node_id, pktno,
                        ps_model.get_node_data(payload)))
                    return

            logger.info("{} ({}) [No slot/session] BS recv PS_PKT {}, data: {}".format(
                str(datetime.fromtimestamp(now_timestamp)), now_timestamp, pktno, ps_model.get_node_data(payload)))
            # Last timestamp for PS_PKT session
            #next_tx_ts = ps_model.nodes_expect_time[-1][-1] + 0.2   # add some delay
            return

        if pkt_type == PacketType.VFS_PKT.index:
            for i, tpl in enumerate(vfs_model.nodes_expect_time):
                node_id, begin_at, end_at = tpl
                if begin_at <= now_timestamp <= end_at:
                    logger.info("{} ({}) [Slot {}: Node {} Session] BS recv VFS_PKT {}, data: {}".format(
                        str(datetime.fromtimestamp(now_timestamp)), now_timestamp, i, node_id, pktno,
                        vfs_model.get_node_data(payload)))
                    return

            logger.info("{} ({}) [No slot/session] BS recv VFS_PKT {}, data: {}".format(
                str(datetime.fromtimestamp(now_timestamp)), now_timestamp, pktno, vfs_model.get_node_data(payload)))
            # Last timestamp for VFS_PKT session
            #next_tx_ts = vfs_model.nodes_expect_time[-1][-1] + 0.2   # add some delay
            return

    def rx_node_callback(ok, payload):    # For Node
        global n_rcvd, n_right, mean_delta, next_tx_ts, stop_rx_ts, ps_end_ts, alloc_index, vf_index, \
            listen_only_to

        n_rcvd += 1

        (pktno,) = struct.unpack('!H', payload[0:2])
        # Filter out incorrect pkt
        if pktno >= wrong_pktno:
            logger.warning("Wrong pktno {}. Drop pkt!".format(pktno))
            return

        try:
            pkt_timestamp_str = payload[2:2+TIMESTAMP_LEN]
            pkt_timestamp = float(pkt_timestamp_str)
        except:
            logger.warning("Timestamp {} is not a float. Drop pkt!".format(pkt_timestamp_str))
            return

        now_timestamp = rx_tb.source.get_time_now().get_real_secs()
        # now_timestamp_str = '{:.3f}'.format(now_timestamp)
        delta = now_timestamp - pkt_timestamp   # +ve: BS earlier; -ve: Node earlier
        if not -5 < delta < 5:
            logger.warning("Delay out-of-range: {}, timestamp {}. Drop pkt!".format(delta, pkt_timestamp_str))
            return

        (pkt_type,) = struct.unpack('!H', payload[2+TIMESTAMP_LEN:2+TIMESTAMP_LEN+2])
        if pkt_type not in [PacketType.BEACON.index, PacketType.ACK_RESPOND.index,
                            PacketType.PS_BROADCAST.index, PacketType.VFS_BROADCAST.index]:
            logger.warning("Invalid pkt_type {}. Drop pkt!".format(pkt_type))
            return
        if listen_only_to and pkt_type not in listen_only_to:
            str_listen_only_to = [PacketType[x].key for x in listen_only_to]
            logger.warning("Interest only in pkt_type {}, not {}. Drop pkt!".format(str_listen_only_to, PacketType[pkt_type].key))
            return

        if pkt_type == PacketType.BEACON.index:
            delta_list.append(delta)
            # Keep delta_list in size limit
            if len(delta_list) > MAX_DELTA_AMT:
                delta_list.pop(0)
            mean_delta = numpy.mean(delta_list)
            # mean_delta_str = '{:07.3f}'.format(delta)
            # Adjust time if needed
            if not -0.05 <= mean_delta <= 0.05:
                rx_tb.source.set_time_now(uhd.time_spec(pkt_timestamp))
                now_timestamp = rx_tb.source.get_time_now().get_real_secs()
                logger.info("Adjust time... New time: {}".format(str(datetime.fromtimestamp(now_timestamp))))

            stop_rx_ts = now_timestamp + 0.5 - COMMAND_DELAY
            # Hack: for RX2400
            if pktno >= MAX_PKT_AMT - 10:
                stop_rx_ts -= 0.3

            logger.info("{} Node recv BEACON {}. BS time: {}, Avg delay: {}".format(
                str(datetime.fromtimestamp(now_timestamp)), pktno, str(datetime.fromtimestamp(pkt_timestamp)), mean_delta))
            # logger.debug("stop_rx_ts {}".format(str(datetime.fromtimestamp(stop_rx_ts))))
            return

        if pkt_type == PacketType.PS_BROADCAST.index:
            node_amount = ps_model.get_node_amount(payload)
            seed = ps_model.get_seed(payload)
            alloc_index = ps_model.compute_alloc_index(node_amount, NODE_ID, seed)
            try:
                begin_timestamp_str = ps_model.get_begin_time_str(payload)
                begin_timestamp = float(begin_timestamp_str)
            except:
                logger.warning("begin_timestamp {} is not a float. Drop pkt!".format(begin_timestamp_str))
                return

            stop_rx_ts = now_timestamp + 0.4
            # TODO: Duo to various delays, adjust a bit to before firing round up second
            next_tx_ts = begin_timestamp + (NODE_SLOT_TIME * alloc_index) - TRANSMIT_DELAY
            # Each node time slot at NODE_SLOT_TIME seconds
            ps_end_ts = begin_timestamp + (NODE_SLOT_TIME * node_amount)

            logger.info("{} Node recv PS_BROADCAST {}, BS time {}, Total {}, Seed {}, Index {}, Delay {}".format(
                str(datetime.fromtimestamp(now_timestamp)), pktno, str(datetime.fromtimestamp(pkt_timestamp)),
                node_amount, seed, alloc_index, delta))
            # logger.debug("begin {}, stop_rx_ts {}, next_tx_ts {}, ps_end_ts {}".format(
            #     str(datetime.fromtimestamp(begin_timestamp)), str(datetime.fromtimestamp(stop_rx_ts)),
            #     str(datetime.fromtimestamp(next_tx_ts)), str(datetime.fromtimestamp(ps_end_ts))))
            return

        if pkt_type == PacketType.VFS_BROADCAST.index:
            node_amount = vfs_model.get_node_amount(payload)
            seed = ps_model.get_seed(payload)
            try:
                begin_timestamp_str = vfs_model.get_begin_time_str(payload)
                begin_timestamp = float(begin_timestamp_str)
            except:
                logger.warning("begin_timestamp {} is not a float. Drop pkt!".format(begin_timestamp_str))
                return
            try:
                v_frame = vfs_model.get_v_frame(payload)
            except:
                logger.warning("Cannot extract v-frame. Drop pkt!")
                return
            vf_index = vfs_model.compute_vf_index(len(v_frame), NODE_ID, seed)
            alloc_index, in_rand_frame = vfs_model.compute_alloc_index(vf_index, NODE_ID, v_frame, node_amount)

            stop_rx_ts = now_timestamp + 0.4
            # TODO: Duo to various delays, adjust a bit to before firing round up second
            next_tx_ts = begin_timestamp + (NODE_SLOT_TIME * alloc_index) - TRANSMIT_DELAY

            logger.info("{} Node recv VFS_BROADCAST {}, BS time {}, Total {}, Seed {}, Delay {}, "
                        "\nv-frame index: {}, alloc-index: {}, fall to rand-frame: {},"
                        "\nv-frame: {}"
                        .format(str(datetime.fromtimestamp(now_timestamp)), pktno,
                                str(datetime.fromtimestamp(pkt_timestamp)),
                                node_amount, seed, delta, vf_index, alloc_index, in_rand_frame, v_frame))
            # logger.debug("begin {}, stop_rx_ts {}, next_tx_ts {}".format(
            #     str(datetime.fromtimestamp(begin_timestamp)), str(datetime.fromtimestamp(stop_rx_ts)),
            #     str(datetime.fromtimestamp(next_tx_ts))))
            return

    def fire_at_absolute_second():
        for i in range(10000):
            check_time = tx_tb.sink.get_time_now().get_real_secs()
            pivot_time = math.ceil(check_time)
            variance = pivot_time - check_time
            if -0.0002 < variance < 0.0002:
                logger.info("Fire at absolute {}".format(str(datetime.fromtimestamp(check_time))))
                break
            time.sleep(0.0001)

    def usrp_sleep(interval_sec):
        wake_up_timestamp = tx_tb.sink.get_time_now().get_real_secs() + interval_sec
        for i in range(50000):
            now_timestamp = tx_tb.sink.get_time_now().get_real_secs()
            if now_timestamp >= wake_up_timestamp:
                break
            time.sleep(0.0001)

    def fire_at_expected_time(start_time):
        for i in range(50000):
            now_timestamp = tx_tb.sink.get_time_now().get_real_secs()
            if now_timestamp >= start_time:
                logger.info("Fire at {}".format(str(datetime.fromtimestamp(now_timestamp))))
                return
            time.sleep(0.0001)
        logger.warning("ALERT!! not fire at {}".format(str(datetime.fromtimestamp(start_time))))

    def check_thread_is_done(max_pkt_amt):
        for i in range(10000):
            if not my_thread.is_alive() and my_iteration >= max_pkt_amt:
                now_ts = tx_tb.sink.get_time_now().get_real_secs()
                logger.debug("{} - thread done - ".format(str(datetime.fromtimestamp(now_ts))))
                return
            time.sleep(0.0001)
        now_ts = tx_tb.sink.get_time_now().get_real_secs()
        logger.debug("ALERT!! thread timeout at {}".format(str(datetime.fromtimestamp(now_ts))))


    #######################################
    # main
    #######################################

    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    expert_grp = parser.add_option_group("Expert")
    parser.add_option("-s", "--size", type="eng_float", default=400,
                      help="set packet size [default=%default]")
    parser.add_option("-M", "--megabytes", type="eng_float", default=1.0,
                      help="set megabytes to transmit [default=%default]")
    parser.add_option("","--discontinuous", action="store_true", default=False,
                      help="enable discontinuous mode")
    parser.add_option("","--from-file", default=None,
                      help="use intput file for packet contents")
    parser.add_option("","--to-file", default=None,
                      help="Output file for modulated samples")
    # Add unused log_file option to prevent 'no such option' error
    parser.add_option("", "--logfile", default=None)
    parser.add_option("", "--scheme", default=None)

    digital.ofdm_mod.add_options(parser, expert_grp)
    digital.ofdm_demod.add_options(parser, expert_grp)
    transmit_path.add_options(parser, expert_grp)
    receive_path.add_options(parser, expert_grp)
    uhd_transmitter.add_options(parser)
    uhd_receiver.add_options(parser)

    (options, args) = parser.parse_args()
    if len(args) != 0:
        logger.error("Parse error: {}\n".format(sys.stderr))
        sys.exit(1)
    logger.info("----------------------------------------------------------")
    logger.info("Input options: \n{}".format(str(options)))
    logger.info("----------------------------------------------------------\n")

    if options.rx_freq is None or options.tx_freq is None:
        logger.error("You must specify -f FREQ or --freq FREQ\n")
        sys.exit(1)
    if options.scheme is None:
        logger.error("You must specify --scheme SCHEME\n")
        sys.exit(1)
    options.scheme = options.scheme.upper()
    if options.scheme not in [str(e) for e in list(Scheme)]:
        logger.error("Not support scheme: {}\n".format(options.scheme))
        sys.exit(1)

    # Decide is BS or Node role
    IS_BS_ROLE = not bool(options.args)

    # build tx/rx tables
    tx_tb = TxTopBlock(options)
    if IS_BS_ROLE:
        rx_tb = RxTopBlock(rx_bs_callback, options)
    else:   # Node role
        rx_tb = RxTopBlock(rx_node_callback, options)

        # Use device serial number as Node ID
        NODE_ID = tx_tb.sink.get_usrp_mboard_serial()
        # Append to required length
        NODE_ID = NODE_ID.zfill(NODE_ID_LEN)
        assert len(NODE_ID) == NODE_ID_LEN, "USRP NODE_ID {} len must be {}".format(NODE_ID, NODE_ID_LEN)
        logger.info("\nNODE ID: {}".format(NODE_ID))

    logger.info("\nClock Rate: {} MHz".format(tx_tb.sink.get_clock_rate() / 1000000))

    logger.info("\n####### Test Protocol: {} #######".format(options.scheme))

    if IS_BS_ROLE:
        logger.info("\nPresume known nodes: {}".format(TEST_NODE_LIST))

    # USRP device aligns with PC time (NTP)
    pc_now = time.time()
    tx_tb.sink.set_time_now(uhd.time_spec(pc_now))
    now_ts = tx_tb.sink.get_time_now().get_real_secs()
    logger.info("\n{} Adjust to PC time: {}\n".format(
                str(datetime.fromtimestamp(time.time())), str(datetime.fromtimestamp(now_ts))))
    # now_ts2 = rx_tb.source.get_time_now().get_real_secs()
    # sys_time = uhd.time_spec.get_system_time().get_real_secs()
    # logger.debug("\n{} Time alignment... Device txtime: {}, rxtime: {}, system time: {}\n".format(
    #              str(datetime.fromtimestamp(time.time())), str(datetime.fromtimestamp(get_time)),
    #              str(datetime.fromtimestamp(now_ts2)), str(datetime.fromtimestamp(sys_time))))

    r = gr.enable_realtime_scheduling()
    if r != gr.RT_OK:
        logger.error("Warning: failed to enable realtime scheduling")

    pkt_size = int(options.size)
    tx_tb.start()
    rx_tb.start()


    for y in range(REPEAT_TEST_COUNT):

        logger.info("\n\n=============================================================================================")
        logger.info("========================================== ROUND {} ==========================================".format(y+1))
        logger.info("=============================================================================================\n\n")


        ##################### SYNC : START #####################

        if IS_BS_ROLE:
            ################# BS #################
            _sync_start = tx_tb.sink.get_time_now().get_real_secs()

            sync_counts = 2
            for z in range(sync_counts):
            # Note: TX cannot be lock initially
                if z == 0 and y == 0:
                    rx_tb.lock()
                else:
                    tx_tb.unlock()

                logger.info("------ Broadcast Beacon ------")
                _start = tx_tb.sink.get_time_now().get_real_secs()
                # BS: Send beacon signals. Time precision thread
                do_every_beacon(0.005, send_beacon_pkt, tx_tb, pkt_size, MAX_PKT_AMT)
                # Clocking thread
                check_thread_is_done(MAX_PKT_AMT)
                _end = rx_tb.source.get_time_now().get_real_secs()
                logger.info(" - duration {} -".format(_end - _start))
                logger.info("------ Broadcast Beacon end --------")
                tx_tb.lock()

                # sleep longer in last loop, finishing sync cycle
                sleep_sec = 0.5 if z == sync_counts - 1 else 0.2
                logger.info("Sleep for {} second\n".format(sleep_sec))
                usrp_sleep(sleep_sec)

            logger.info(" - Sync duration {} -\n".format(rx_tb.source.get_time_now().get_real_secs() - _sync_start))

            # # Deprecated. PROF TSENG: No need response-beacon, might cause collision
            # rx_tb.unlock()
            # logger.info("------ Listening ------")
            # next_tx_ts = 0  # reset next_tx
            # while next_tx_ts == 0 or next_tx_ts > now_ts:
            #     time.sleep(0.01)
            #     now_ts = rx_tb.source.get_time_now().get_real_secs()
            #     # logger.debug("now {} next {}".format(str(datetime.fromtimestamp(now_ts)), str(datetime.fromtimestamp(next_tx_ts))))
            # logger.info("------ Stop listen at {} ------".format(str(datetime.fromtimestamp(now_ts))))
            # rx_tb.lock()
            ################ BS end ##############

        else:
            ################ Node ################
            # Note: TX cannot be lock initially
            if y != 0:
                rx_tb.unlock()

            logger.info("------ Listening ------")
            stop_rx_ts = 0  # reset
            while stop_rx_ts == 0 or stop_rx_ts > now_ts:
                time.sleep(0.01)
                now_ts = rx_tb.source.get_time_now().get_real_secs()
                # logger.debug("now {} next {}".format(str(datetime.fromtimestamp(now_ts)), str(datetime.fromtimestamp(stop_rx_ts))))
            rx_tb.lock()
            logger.info("------ Stop listen at {} ------".format(str(datetime.fromtimestamp(now_ts))))

            # Deprecated. PROF TSENG: No need response-beacon, might cause collision
            # for z in range(2):
            #
            #     if z != 0:
            #         rx_tb.unlock()
            #     logger.info("------ Listening ------")
            #     next_tx_ts = 0  # reset next_tx
            #     while next_tx_ts == 0 or next_tx_ts > now_ts:
            #         time.sleep(0.01)
            #         now_ts = rx_tb.source.get_time_now().get_real_secs()
            #         # logger.debug("now {} next {}".format(str(datetime.fromtimestamp(now_ts)), str(datetime.fromtimestamp(next_tx_ts))))
            #     logger.info("------ Stop listen at {} ------".format(str(datetime.fromtimestamp(now_ts))))
            #     rx_tb.lock()
            #
            #     if z != 0:
            #         tx_tb.unlock()
            #     logger.info("------ Send Response Beacon ------")
            #     _start = tx_tb.sink.get_time_now().get_real_secs()
            #     # Node: Send response-beacon signals. Time precision thread
            #     do_every_beacon(0.005, send_resp_beacon_pkt, tx_tb, pkt_size, MAX_PKT_AMT)
            #     # Clocking thread
            #     check_thread_is_done(MAX_PKT_AMT)
            #     _end = rx_tb.source.get_time_now().get_real_secs()
            #     logger.info(" - duration {} -".format(_end - _start))
            #     logger.info("------ Send Response Beacon end ------")
            #     tx_tb.lock()
            ################ Node end ############

        ######################## SYNC : END #########################

        if options.scheme == Scheme.PS.key:
            ################### Perfect Scheme: START ###################

            if IS_BS_ROLE:
                ################# BS #################
                # Deprecated
                # nodes_sync_delta.update({NODE_ID_A: [1, 2, 3],
                #                          NODE_ID_B: [4, 5, 6],
                #                          '0000000003': [7, 8, 9],
                #                          '0000000004': [10, 11, 12],
                #                          '0000000005': [13, 14, 15]})
                # node_amount = len(nodes_sync_delta)

                # rx_tb.lock()

                # Mark Frame T start time
                _ps_start = tx_tb.sink.get_time_now().get_real_secs()

                # calculate perfect seed
                _start = tx_tb.sink.get_time_now().get_real_secs()
                ps_model.generate_perfect_seed(TEST_NODE_LIST)
                _end = rx_tb.source.get_time_now().get_real_secs()
                logger.info(" - duration {} -".format(_end - _start))

                tx_tb.unlock()
                logger.info("------ Broadcast PS packets ------")
                # To ensure broadcast end within a full second, adjust to start at absolute second
                fire_at_absolute_second()

                _start = tx_tb.sink.get_time_now().get_real_secs()
                do_every_protocol_bs(0.005, ps_model.broadcast_ps_pkt, tx_tb, pkt_size, len(TEST_NODE_LIST), MAX_PKT_AMT)
                # Clocking thread
                check_thread_is_done(MAX_PKT_AMT)
                _end = rx_tb.source.get_time_now().get_real_secs()
                logger.info(" - duration {} -".format(_end - _start))
                logger.info("------ Broadcast PS end ------")
                tx_tb.lock()

                rx_tb.unlock()
                logger.info("------ Listen PS packets start ------")
                listen_only_to = [PacketType.PS_PKT.index]
                _start = tx_tb.sink.get_time_now().get_real_secs()
                # Listen end time is after last node transmission ended. Add some misc delay
                stop_rx_ts = ps_model.nodes_expect_time[-1][-1] + 0.5
                while stop_rx_ts == 0 or stop_rx_ts > now_ts:
                    time.sleep(0.01)
                    now_ts = rx_tb.source.get_time_now().get_real_secs()
                    # logger.debug("now {} next {}".format(str(datetime.fromtimestamp(now_ts)), str(datetime.fromtimestamp(next_tx_ts))))
                _end = rx_tb.source.get_time_now().get_real_secs()
                logger.info(" - duration {} -".format(_end - _start))
                logger.info("------ Listen PS packets end ------")
                listen_only_to = []
                rx_tb.lock()

                now_ts = rx_tb.source.get_time_now().get_real_secs()
                logger.info("\n - PS duration {} -".format(now_ts - _ps_start))
                logger.info("------ PS cycle ends at {} ------\n".format(str(datetime.fromtimestamp(now_ts))))

                # logger.info("Sleep for 0.2 second")
                # usrp_sleep(0.2)
                ################ BS end ##############

            else:
                ################ Node ################
                rx_tb.unlock()
                logger.info("------ Listening PS broadcast ------")
                listen_only_to = [PacketType.PS_BROADCAST.index]
                stop_rx_ts = 0  # reset
                while stop_rx_ts == 0 or stop_rx_ts > now_ts:
                    time.sleep(0.01)
                    now_ts = rx_tb.source.get_time_now().get_real_secs()
                    # logger.debug("now {} next {}".format(str(datetime.fromtimestamp(now_ts)), str(datetime.fromtimestamp(stop_rx_ts))))
                logger.info("------ Stop listen PS broadcast at {} ------".format(str(datetime.fromtimestamp(now_ts))))
                listen_only_to = []
                rx_tb.lock()

                # TODO: Adjust to node alloc period
                assert alloc_index != -1, "alloc_index is -1"

                logger.info("------ Ready to send PS packets ------")
                if y != 0:
                    tx_tb.unlock()

                fire_at_expected_time(next_tx_ts + COMMAND_DELAY)

                _start = tx_tb.sink.get_time_now().get_real_secs()
                ps_data = "Hello, I am node {}".format(NODE_ID)
                do_every_protocol_node(0.005, ps_model.send_ps_pkt, NODE_ID, tx_tb, pkt_size, ps_data, MAX_PKT_AMT_FOR_NODE)
                # Clocking thread
                check_thread_is_done(MAX_PKT_AMT_FOR_NODE)
                _end = rx_tb.source.get_time_now().get_real_secs()
                logger.info(" - duration {} -".format(_end - _start))
                logger.info("------ Send PS packets end ------")
                tx_tb.lock()

                # Node wait until PS cycle is over
                now_ts = rx_tb.source.get_time_now().get_real_secs()
                usrp_sleep(ps_end_ts - now_ts + COMMAND_DELAY)

                now_ts = rx_tb.source.get_time_now().get_real_secs()
                logger.info("\n------ PS cycle ends at {} ------\n".format(str(datetime.fromtimestamp(now_ts))))
                ################ Node end ############

            ##################### Perfect Scheme: END #####################

        elif options.scheme == Scheme.VFS.key:
            ################### Virtual Frame Scheme: START ###################

            if IS_BS_ROLE:
                ################# BS #################
                # Deprecated
                # nodes_sync_delta.update({NODE_ID_A: [1, 2, 3],
                #                          NODE_ID_B: [4, 5, 6],
                #                          '0000000003': [7, 8, 9],
                #                          '0000000004': [10, 11, 12],
                #                          '0000000005': [13, 14, 15]})
                # node_amount = len(nodes_sync_delta)

                # rx_tb.lock()

                # Mark Frame T start time & expected end time
                vfs_start_ts = tx_tb.sink.get_time_now().get_real_secs()
                vfs_end_ts = vfs_start_ts + FRAME_TIME_T - 0.01     # give a bit deplay for ending

                # calculate VFS seed, v-frame & rand-frame
                _start = tx_tb.sink.get_time_now().get_real_secs()
                vfs_model.generate_seed_v_frame_rand_frame(TEST_NODE_LIST)
                _end = rx_tb.source.get_time_now().get_real_secs()
                logger.info(" - duration {} -".format(_end - _start))

                tx_tb.unlock()
                logger.info("------ Broadcast VFS packets ------")
                # To ensure broadcast end within a full second, adjust to start at absolute second
                fire_at_absolute_second()

                _start = tx_tb.sink.get_time_now().get_real_secs()
                do_every_protocol_bs(0.005, vfs_model.broadcast_vfs_pkt, tx_tb, pkt_size, len(TEST_NODE_LIST), MAX_PKT_AMT)
                # Clocking thread
                check_thread_is_done(MAX_PKT_AMT)
                _end = rx_tb.source.get_time_now().get_real_secs()
                logger.info(" - duration {} -".format(_end - _start))
                logger.info("------ Broadcast VFS end ------")
                tx_tb.lock()

                rx_tb.unlock()
                logger.info("------ Listen VFS packets start ------")
                listen_only_to = [PacketType.VFS_PKT.index]
                _start = tx_tb.sink.get_time_now().get_real_secs()
                # Listen end time is after last node transmission ended, or till frame T ended.
                stop_rx_ts = vfs_model.nodes_expect_time[-1][-1] + 0.5  # Add misc delay
                while stop_rx_ts == 0 or stop_rx_ts > now_ts or vfs_end_ts > now_ts:
                    time.sleep(0.01)
                    now_ts = rx_tb.source.get_time_now().get_real_secs()
                    # logger.debug("now {} next {}".format(str(datetime.fromtimestamp(now_ts)), str(datetime.fromtimestamp(next_tx_ts))))
                _end = rx_tb.source.get_time_now().get_real_secs()
                logger.info(" - duration {} -".format(_end - _start))
                logger.info("------ Listen VFS packets end ------")
                listen_only_to = []
                rx_tb.lock()

                now_ts = rx_tb.source.get_time_now().get_real_secs()
                logger.info("\n - VFS duration {} -".format(now_ts - vfs_start_ts))
                logger.info("------ VFS cycle ends at {} ------\n".format(str(datetime.fromtimestamp(now_ts))))

                # logger.info("Sleep for 0.2 second")
                # usrp_sleep(0.2)
                ################# BS end #############

            else:
                ################ Node ################
                # Mark Frame T start time & expected end time
                vfs_start_ts = tx_tb.sink.get_time_now().get_real_secs()
                vfs_end_ts = vfs_start_ts + FRAME_TIME_T - 0.01     # give a bit deplay for ending

                rx_tb.unlock()
                logger.info("------ Listening VFS broadcast ------")
                listen_only_to = [PacketType.VFS_BROADCAST.index]
                stop_rx_ts = 0  # reset
                while stop_rx_ts == 0 or stop_rx_ts > now_ts:
                    time.sleep(0.01)
                    now_ts = rx_tb.source.get_time_now().get_real_secs()
                    # logger.debug("now {} next {}".format(str(datetime.fromtimestamp(now_ts)), str(datetime.fromtimestamp(stop_rx_ts))))
                logger.info("------ Stop listen VFS broadcast at {} ------".format(str(datetime.fromtimestamp(now_ts))))
                listen_only_to = []
                rx_tb.lock()

                # TODO: Adjust to node alloc period
                if alloc_index == -1:
                    logger.warning("WARNING: alloc_index is -1, cannot join this session. Skip...")
                    time.sleep(7)
                    continue
                # assert alloc_index != -1, "alloc_index is -1"

                logger.info("------ Ready to send VFS packets ------")
                if y != 0:
                    tx_tb.unlock()

                fire_at_expected_time(next_tx_ts + COMMAND_DELAY)

                _start = tx_tb.sink.get_time_now().get_real_secs()
                vfs_data = "Hello, I am node {}".format(NODE_ID)
                do_every_protocol_node(0.005, vfs_model.send_vfs_pkt, NODE_ID, tx_tb, pkt_size, vfs_data, MAX_PKT_AMT_FOR_NODE)
                # Clocking thread
                check_thread_is_done(MAX_PKT_AMT_FOR_NODE)
                _end = rx_tb.source.get_time_now().get_real_secs()
                logger.info(" - duration {} -".format(_end - _start))
                logger.info("------ Send VFS packets end ------")
                tx_tb.lock()

                # Node wait until VFS cycle is over
                now_ts = rx_tb.source.get_time_now().get_real_secs()
                usrp_sleep(vfs_end_ts - now_ts + COMMAND_DELAY)

                now_ts = rx_tb.source.get_time_now().get_real_secs()
                logger.info("\n - VFS duration {} -".format(now_ts - vfs_start_ts))
                logger.info("------ VFS cycle ends at {} ------\n".format(str(datetime.fromtimestamp(now_ts))))
                ################ Node end ############

            ##################### Virtual Frame Scheme: END #####################

    #tx_tb.unlock()
    #tx_tb.wait()
    #rx_tb.unlock()
    #rx_tb.wait()
    tx_tb.stop()
    rx_tb.stop()

    logger.info("\n\n=============================================================================================")
    logger.info("========================================= TEST END ==========================================")
    logger.info("=============================================================================================\n\n")

    sys.exit(0)
コード例 #18
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block Usrp New Diff Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block Usrp New Diff Test")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.variable_qtgui_chooser_0_1_0 = variable_qtgui_chooser_0_1_0 = 0
        self.variable_qtgui_chooser_0_0 = variable_qtgui_chooser_0_0 = 0
        self.samp_rate = samp_rate = 100000000/256
        self.gain_rx = gain_rx = 0
        self.enabler = enabler = 0
        self.center_freq = center_freq = 2.4e9
        self.cal_tone_freq = cal_tone_freq = 1000
        self.cal_freq = cal_freq = 1000

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_chooser_0_1_0_options = (1, 0, )
        self._variable_qtgui_chooser_0_1_0_labels = ("Stop", "Running", )
        self._variable_qtgui_chooser_0_1_0_group_box = Qt.QGroupBox("Sync System")
        self._variable_qtgui_chooser_0_1_0_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._variable_qtgui_chooser_0_1_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_1_0_group_box.setLayout(self._variable_qtgui_chooser_0_1_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_1_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_1_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_1_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_1_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_0_options.index(i)))
        self._variable_qtgui_chooser_0_1_0_callback(self.variable_qtgui_chooser_0_1_0)
        self._variable_qtgui_chooser_0_1_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_1_0(self._variable_qtgui_chooser_0_1_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_0_group_box)
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "Input")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "Post Gain Correct")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Post Phase Correct")
        self.top_layout.addWidget(self.tab)
        self._variable_qtgui_chooser_0_0_options = (0, 1, )
        self._variable_qtgui_chooser_0_0_labels = ("Enable", "Disable", )
        self._variable_qtgui_chooser_0_0_group_box = Qt.QGroupBox("Source Enable")
        self._variable_qtgui_chooser_0_0_box = Qt.QVBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._variable_qtgui_chooser_0_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_options.index(i)))
        self._variable_qtgui_chooser_0_0_callback(self.variable_qtgui_chooser_0_0)
        self._variable_qtgui_chooser_0_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_0(self._variable_qtgui_chooser_0_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_group_box)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(("addr0=192.168.30.2,addr1=192.168.70.2,addr2=192.168.20.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(3),
        	),
        )
        self.uhd_usrp_source_0_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0_0.set_time_source("external", 0)
        self.uhd_usrp_source_0_0.set_clock_source("external", 1)
        self.uhd_usrp_source_0_0.set_time_source("external", 1)
        self.uhd_usrp_source_0_0.set_clock_source("external", 2)
        self.uhd_usrp_source_0_0.set_time_source("external", 2)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 0)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 1)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 1)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 2)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 2)
        self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.40.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0_0_0.set_gain(10, 0)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
        	100, #size
        	samp_rate, #samp_rate
        	"Input", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_1.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_1.enable_autoscale(True)
        self.qtgui_time_sink_x_0_1.enable_grid(False)
        self.qtgui_time_sink_x_0_1.enable_control_panel(True)
        
        if not True:
          self.qtgui_time_sink_x_0_1.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	100, #size
        	samp_rate, #samp_rate
        	"Post Gain Correct", #name
        	2 #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_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(True)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win)
        self._enabler_options = (0, 1, )
        self._enabler_labels = ("Enable", "Disable", )
        self._enabler_group_box = Qt.QGroupBox("Gain Correct (Do Not Renable)")
        self._enabler_box = Qt.QVBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._enabler_button_group = variable_chooser_button_group()
        self._enabler_group_box.setLayout(self._enabler_box)
        for i, label in enumerate(self._enabler_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._enabler_box.addWidget(radio_button)
        	self._enabler_button_group.addButton(radio_button, i)
        self._enabler_callback = lambda i: Qt.QMetaObject.invokeMethod(self._enabler_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._enabler_options.index(i)))
        self._enabler_callback(self.enabler)
        self._enabler_button_group.buttonClicked[int].connect(
        	lambda i: self.set_enabler(self._enabler_options[i]))
        self.top_layout.addWidget(self._enabler_group_box)
        self.delay_correct_hier_0 = delay_correct_hier(
            cal_tone_freq=cal_freq,
            samp_rate=samp_rate,
        )
        self.correct_gains_hier_0 = correct_gains_hier(
            cal_tone_freq=cal_freq,
            samp_rate_0=samp_rate,
        )
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_1_0), 1000)
        self.blocks_complex_to_real_0_2 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_0_2 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.correct_gains_hier_0, 'Trigger'))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.uhd_usrp_sink_0_0_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_complex_to_real_0_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.blocks_complex_to_real_0_0_2, 0), (self.qtgui_time_sink_x_0_1, 1))    
        self.connect((self.blocks_complex_to_real_0_2, 0), (self.qtgui_time_sink_x_0_1, 0))    
        self.connect((self.correct_gains_hier_0, 2), (self.blocks_null_sink_0, 0))    
        self.connect((self.correct_gains_hier_0, 0), (self.delay_correct_hier_0, 0))    
        self.connect((self.correct_gains_hier_0, 1), (self.delay_correct_hier_0, 1))    
        self.connect((self.delay_correct_hier_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.delay_correct_hier_0, 1), (self.blocks_complex_to_real_0_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_complex_to_real_0_0_2, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_complex_to_real_0_2, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.correct_gains_hier_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.correct_gains_hier_0, 1))    
        self.connect((self.uhd_usrp_source_0_0, 2), (self.correct_gains_hier_0, 2))    
コード例 #19
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Tx")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 50
        self.samp_rate = samp_rate = 10e6
        self.period = period = 100
        self.pdu_length = pdu_length = 100
        self.out_buf_size = out_buf_size = 96000
        self.mult = mult = .4
        self.lo_offset = lo_offset = 11e6
        self.freq = freq = 2.422e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label='tx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[10e6, 20e6],
        	labels=["10 Mhz", "20 Mhz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _period_sizer = wx.BoxSizer(wx.VERTICAL)
        self._period_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_period_sizer,
        	value=self.period,
        	callback=self.set_period,
        	label='period',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._period_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_period_sizer,
        	value=self.period,
        	callback=self.set_period,
        	minimum=1,
        	maximum=10000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_period_sizer)
        _pdu_length_sizer = wx.BoxSizer(wx.VERTICAL)
        self._pdu_length_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_pdu_length_sizer,
        	value=self.pdu_length,
        	callback=self.set_pdu_length,
        	label='pdu_length',
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._pdu_length_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_pdu_length_sizer,
        	value=self.pdu_length,
        	callback=self.set_pdu_length,
        	minimum=0,
        	maximum=1500,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Add(_pdu_length_sizer)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	label='mult',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	minimum=0,
        	maximum=2,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_sizer)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	labels=['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'],
        )
        self.Add(self._freq_chooser)
        self._encoding_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.encoding,
        	callback=self.set_encoding,
        	label="Encoding",
        	choices=[0,1,2,3,4,5,6,7],
        	labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=encoding,
            sensitivity=0.56,
        )
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0x02, 0x11, 0x87, 0xBA, 0x68, 0x3B]))
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.01, 100, 1000)
        (self.foo_packet_pad2_0).set_min_output_buffer(96000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length))), period)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.blocks_null_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0))    
コード例 #20
0
    def __init__(
            self,
            addr='serial=314FC3C',
            note='wire format = complex int12; clock rate = 60M, samp_rate = 30M',
            path="/captures/20191214",
            signal_type='NEXRAD',
            usrp_type='B200'):
        gr.top_block.__init__(self, "sigmf_rx_uhd")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("sigmf_rx_uhd")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.addr = addr
        self.note = note
        self.path = path
        self.signal_type = signal_type
        self.usrp_type = usrp_type

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%SZ")
        self.fn = fn = "{:s}_{:s}".format(signal_type.upper(), ts_str)
        self.samp_rate = samp_rate = 15e6
        self.rx_gain = rx_gain = 65
        self.rx_freq = rx_freq = 2831e6
        self.fp = fp = "{:s}/{:s}".format(path, fn)

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
            lambda: self.set_samp_rate(
                eng_notation.str_to_num(
                    str(self._samp_rate_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._samp_rate_tool_bar)
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel('Gain' + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(
                str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_gain_tool_bar)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('Freq [Hz]' + ": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq(
            eng_notation.str_to_num(
                str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join((addr, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_clock_rate(60e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_clock_source('external', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(rx_freq, samp_rate / 2), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0.set_auto_iq_balance(True, 0)
        self.fosphor_glfw_sink_c_0 = fosphor.glfw_sink_c()
        self.fosphor_glfw_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_glfw_sink_c_0.set_frequency_range(0, samp_rate)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.fosphor_glfw_sink_c_0, 0))
コード例 #21
0
ファイル: per_test.py プロジェクト: cschmol/gr-inets
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_tx_gain = range_tx_gain = 15
        self.range_rx_gain = range_rx_gain = 18
        self.range_mu = range_mu = 0.4
        self.range_freq = range_freq = 3.5e9
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = "{:2.1f} GHz".format(float((77e9-range_freq))/1e9)
        self.tx_gain = tx_gain = range_tx_gain
        self.threshold = threshold = 50
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = range_rx_gain
        
        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)
          
        self.range_noise = range_noise = 0
        self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base()
        self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.mu = mu = range_mu
        self.freq = freq = range_freq
        self.diff_preamble_256 = diff_preamble_256 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128]
        self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "TX")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "RX")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Demod")
        self.top_layout.addWidget(self.tab)
        self._range_noise_range = Range(0, 0.1, 0.005, 0, 200)
        self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, "noise", "counter_slider", float)
        self.top_layout.addWidget(self._range_noise_win)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._variable_qtgui_label_0_formatter = None
        else:
          self._variable_qtgui_label_0_formatter = lambda x: x
        
        self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel("RF Frequency"+": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 0,1,1,1)
          
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq+100e6, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self._range_tx_gain_range = Range(0, 15, 1, 15, 200)
        self._range_tx_gain_win = RangeWidget(self._range_tx_gain_range, self.set_range_tx_gain, "Tx Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_tx_gain_win, 1,1,1,1)
        self._range_rx_gain_range = Range(0, 60, 1, 18, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1)
        self._range_mu_range = Range(0, 1, 0.01, 0.4, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1)
        self._range_freq_range = Range(2.5e9, 4e9, 100e6, 3.5e9, 200)
        self._range_freq_win = RangeWidget(self._range_freq_range, self.set_range_freq, "IF Frequency", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_freq_win, 0,0,1,1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	256, #size
        	1, #samp_rate
        	"Frequency Offset", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 1, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	100000, #size
        	samp_rate, #samp_rate
        	"Correlation", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 200)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 20, 0, 1, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	128, #size
        	"Payload", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, "fd")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(True)
        
        if not True:
          self.qtgui_const_sink_x_0_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "red", "red", "red",
                  "red", "red", "red", "red", "red"]
        styles = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0,
                   0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.inets_radio_0 = inets_radio(
            constellation=qpsk_mod,
            matched_filter_coeff=rrc,
            mu=mu,
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            threshold=threshold,
        )
        self.inets_per_logger_0 = inets.per_logger()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((range_noise, ))
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 1024)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_radio_0, 'in'))    
        self.msg_connect((self.inets_radio_0, 'out'), (self.inets_per_logger_0, 'payload_in'))    
        self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_per_logger_0, 'snr_in'))    
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.inets_radio_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.inets_radio_0, 2), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.inets_radio_0, 1), (self.blocks_complex_to_mag_0_0, 0))    
        self.connect((self.inets_radio_0, 5), (self.blocks_null_sink_0, 0))    
        self.connect((self.inets_radio_0, 6), (self.blocks_null_sink_0_0, 0))    
        self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0))    
        self.connect((self.inets_radio_0, 4), (self.qtgui_time_sink_x_0_0, 0))    
        self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_add_xx_0, 0))    
コード例 #22
0
    def __init__(self):
        gr.top_block.__init__(self, "Transceiver Test for Client Node")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Transceiver Test for Client Node")
        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", "inets_transceiver_test_client")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 0
        self.range_mu = range_mu = 0.6
        self.threshold = threshold = 50
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = range_rx_gain

        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)

        self.range_noise = range_noise = 0
        self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base()
        self.qam16_mod = qam16_mod = gnuradio.digital.qam_constellation(16,False).base()
        self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.mu = mu = range_mu
        self.diff_preamble_256 = diff_preamble_256 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128]
        self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "TX")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "RX")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Demod")
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, "RSSI")
        self.top_layout.addWidget(self.tab)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(2e9, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(1.5e9, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self._range_rx_gain_range = Range(0, 60, 1, 0, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1)
        self._range_noise_range = Range(0, 0.01, 0.00001, 0, 200)
        self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, "noise", "counter_slider", float)
        self.top_layout.addWidget(self._range_noise_win)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	1000000, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-80, -40)

        self.qtgui_time_sink_x_1.set_y_label("Amplitude", "")

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

        if not True:
          self.qtgui_time_sink_x_1.disable_legend()

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.tab_layout_3.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	256, #size
        	1, #samp_rate
        	"Frequency Offset", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "")

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

        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [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(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	100000, #size
        	samp_rate / 4, #samp_rate
        	"Correlation", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 200)

        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, 20, 0, 1, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        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(3):
            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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
        	1024, #size
        	"TX Constellation", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(True)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_0_0_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	1024, #size
        	"Payload", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "fd")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(True)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
          self.qtgui_const_sink_x_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.inets_rssi_0 = inets.rssi(0.00004)
        self.inets_radio_0 = inets_radio(
            constellation=qpsk_mod,
            matched_filter_coeff=rrc,
            mu=mu,
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            threshold=threshold,
        )
        self.inets_per_logger_0 = inets.per_logger()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(1, 1, 0)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((10, ))
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_radio_0, 'in'))
        self.msg_connect((self.inets_radio_0, 'out'), (self.inets_per_logger_0, 'payload_in'))
        self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_per_logger_0, 'snr_in'))
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.inets_radio_0, 5), (self.blocks_char_to_float_0, 0))
        self.connect((self.inets_radio_0, 2), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.inets_radio_0, 1), (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.inets_radio_0, 6), (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.inets_radio_0, 4), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.inets_rssi_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.inets_rssi_0, 1), (self.blocks_null_sink_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.inets_radio_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.inets_rssi_0, 0))
コード例 #23
0
    def __init__(self):
        gr.top_block.__init__(self, "Wwv X310 Corr 1")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wwv X310 Corr 1")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y-%m-%dT%H:%M:%S.%fZ")
        self.y_min = y_min = -60
        self.y_max = y_max = 0
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = ts_str
        self.samp_rate = samp_rate = 500e3
        self.rx_freq = rx_freq = 4.51e6
        self.nfft = nfft = 1024*32
        self.lpf_cutoff = lpf_cutoff = 50e3
        self.delay = delay = 0
        self.decim = decim = 1
        self.decay_rate = decay_rate = 20e-3
        self.c_ms = c_ms = 299792458

        ##################################################
        # Blocks
        ##################################################
        self.main_tab = Qt.QTabWidget()
        self.main_tab_widget_0 = Qt.QWidget()
        self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0)
        self.main_tab_grid_layout_0 = Qt.QGridLayout()
        self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0)
        self.main_tab.addTab(self.main_tab_widget_0, 'Main')
        self.main_tab_widget_1 = Qt.QWidget()
        self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1)
        self.main_tab_grid_layout_1 = Qt.QGridLayout()
        self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1)
        self.main_tab.addTab(self.main_tab_widget_1, 'Corr')
        self.top_grid_layout.addWidget(self.main_tab, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._y_min_tool_bar = Qt.QToolBar(self)
        self._y_min_tool_bar.addWidget(Qt.QLabel('FREQ'+": "))
        self._y_min_line_edit = Qt.QLineEdit(str(self.y_min))
        self._y_min_tool_bar.addWidget(self._y_min_line_edit)
        self._y_min_line_edit.returnPressed.connect(
        	lambda: self.set_y_min(eng_notation.str_to_num(str(self._y_min_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._y_min_tool_bar, 8, 4, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(4, 5):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._y_max_tool_bar = Qt.QToolBar(self)
        self._y_max_tool_bar.addWidget(Qt.QLabel('FREQ'+": "))
        self._y_max_line_edit = Qt.QLineEdit(str(self.y_max))
        self._y_max_tool_bar.addWidget(self._y_max_line_edit)
        self._y_max_line_edit.returnPressed.connect(
        	lambda: self.set_y_max(eng_notation.str_to_num(str(self._y_max_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._y_max_tool_bar, 8, 5, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(5, 6):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE'+": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
        	lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._samp_rate_tool_bar, 8, 0, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 1):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ'+": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(
        	lambda: self.set_rx_freq(eng_notation.str_to_num(str(self._rx_freq_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._rx_freq_tool_bar, 8, 1, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(1, 2):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff"+": "))
        self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff))
        self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit)
        self._lpf_cutoff_line_edit.returnPressed.connect(
        	lambda: self.set_lpf_cutoff(eng_notation.str_to_num(str(self._lpf_cutoff_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_0.addWidget(self._lpf_cutoff_tool_bar, 8, 3, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(3, 4):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._delay_tool_bar = Qt.QToolBar(self)
        self._delay_tool_bar.addWidget(Qt.QLabel('corr_delay'+": "))
        self._delay_line_edit = Qt.QLineEdit(str(self.delay))
        self._delay_tool_bar.addWidget(self._delay_line_edit)
        self._delay_line_edit.returnPressed.connect(
        	lambda: self.set_delay(eng_notation.str_to_num(str(self._delay_line_edit.text().toAscii()))))
        self.main_tab_grid_layout_1.addWidget(self._delay_tool_bar, 8, 0, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 1):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self._decay_rate_options = (100e-6, 65e-3, 20e-3, )
        self._decay_rate_labels = ('Fast', 'Medium', 'Slow', )
        self._decay_rate_group_box = Qt.QGroupBox("decay_rate")
        self._decay_rate_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._decay_rate_button_group = variable_chooser_button_group()
        self._decay_rate_group_box.setLayout(self._decay_rate_box)
        for i, label in enumerate(self._decay_rate_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._decay_rate_box.addWidget(radio_button)
        	self._decay_rate_button_group.addButton(radio_button, i)
        self._decay_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._decay_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._decay_rate_options.index(i)))
        self._decay_rate_callback(self.decay_rate)
        self._decay_rate_button_group.buttonClicked[int].connect(
        	lambda i: self.set_decay_rate(self._decay_rate_options[i]))
        self.main_tab_grid_layout_0.addWidget(self._decay_rate_group_box, 8, 2, 1, 1)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(2, 3):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

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

        self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Start Time [UTC]'+": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label)
        self.main_tab_grid_layout_0.addWidget(self._variable_qtgui_label_0_tool_bar, 8, 6, 1, 2)
        for r in range(8, 9):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(6, 8):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.uhd_usrp_source_1 = uhd.usrp_source(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(2),
        	),
        )
        self.uhd_usrp_source_1.set_clock_source('gpsdo', 0)
        self.uhd_usrp_source_1.set_time_source('gpsdo', 0)
        self.uhd_usrp_source_1.set_subdev_spec('A:AB B:AB', 0)
        self.uhd_usrp_source_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_1.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 0)
        self.uhd_usrp_source_1.set_gain(0, 0)
        self.uhd_usrp_source_1.set_antenna('A', 0)
        self.uhd_usrp_source_1.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_1.set_auto_iq_balance(True, 0)
        self.uhd_usrp_source_1.set_center_freq(uhd.tune_request(rx_freq), 1)
        self.uhd_usrp_source_1.set_gain(0, 1)
        self.uhd_usrp_source_1.set_antenna('A', 1)
        self.uhd_usrp_source_1.set_auto_dc_offset(True, 1)
        self.uhd_usrp_source_1.set_auto_iq_balance(True, 1)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rx_freq, #fc
        	samp_rate / decim, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0_0.disable_legend()

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

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 4, 4, 4, 4)
        for r in range(4, 8):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rx_freq, #fc
        	samp_rate / decim, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

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

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4)
        for r in range(4, 8):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	10, #size
        	samp_rate/decim, #samp_rate
        	"", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0_0.set_y_axis(-20, 20)

        self.qtgui_time_sink_x_0_0.set_y_label('Range Delta [km]', "")

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

        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win, 4, 0, 2, 4)
        for r in range(4, 6):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	nfft, #size
        	samp_rate/decim, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

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

        labels = ['Delay', '', 'Range Delta', '', '',
                  '', '', '', '', '']
        units = ['[usec]', '', '[km]', '', '',
                 '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(3):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(True)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 6, 0, 1, 2)
        for r in range(6, 7):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 2):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_histogram_sink_x_0_0 = qtgui.histogram_sink_f(
        	20,
        	1000,
                0,
                100e4,
        	"",
        	1
        )

        self.qtgui_histogram_sink_x_0_0.set_update_time(0.010)
        self.qtgui_histogram_sink_x_0_0.enable_autoscale(True)
        self.qtgui_histogram_sink_x_0_0.enable_accumulate(True)
        self.qtgui_histogram_sink_x_0_0.enable_grid(False)
        self.qtgui_histogram_sink_x_0_0.enable_axis_labels(True)

        if not True:
          self.qtgui_histogram_sink_x_0_0.disable_legend()

        labels = ['Correlation Magnitude', 'Corr Mag', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_histogram_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_histogram_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_histogram_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_histogram_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_histogram_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_histogram_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_histogram_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_histogram_sink_x_0_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_0_win, 0, 0, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f(
        	20,
        	2000,
                -25*1/(samp_rate/decim) *c_ms / 1000.0,
                25*1/(samp_rate/decim) *c_ms / 1000.0,
        	"",
        	1
        )

        self.qtgui_histogram_sink_x_0.set_update_time(0.010)
        self.qtgui_histogram_sink_x_0.enable_autoscale(True)
        self.qtgui_histogram_sink_x_0.enable_accumulate(True)
        self.qtgui_histogram_sink_x_0.enable_grid(False)
        self.qtgui_histogram_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_histogram_sink_x_0.disable_legend()

        labels = ['Range Delta [km]', 'Corr Mag', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_histogram_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_histogram_sink_x_0_win = sip.wrapinstance(self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_1.addWidget(self._qtgui_histogram_sink_x_0_win, 4, 4, 2, 4)
        for r in range(4, 6):
            self.main_tab_grid_layout_1.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_1.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rx_freq, #fc
        	samp_rate /decim, #bw
        	"E/W Dipole", #name
        	2 #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0_0.set_y_axis(y_min, y_max)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 4, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(4, 8):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rx_freq, #fc
        	samp_rate / decim, #bw
        	"N/S Dipole", #name
        	2 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(y_min, y_max)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.main_tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4)
        for r in range(0, 4):
            self.main_tab_grid_layout_0.setRowStretch(r, 1)
        for c in range(0, 4):
            self.main_tab_grid_layout_0.setColumnStretch(c, 1)
        self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate/decim, lpf_cutoff, 1e3, firdes.WIN_HAMMING, 6.76))
        self.fft_vxx_2 = fft.fft_vcc(nfft, True, (window.blackmanharris(nfft)), True, 4)
        self.fft_vxx_1 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4)
        self.fft_vxx_0 = fft.fft_vcc(nfft, False, (window.blackmanharris(nfft)), False, 4)
        self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_float*1, nfft)
        self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, nfft)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short*1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1/(samp_rate/decim) *c_ms / 1000.0, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1/(samp_rate/decim) * 1e6, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(nfft)
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(10, .1, 4000, 1)
        self.blocks_max_xx_0 = blocks.max_ff(nfft,1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(delay))
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(nfft)
        self.blocks_argmax_xx_0 = blocks.argmax_fs(nfft)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-nfft/2.0, ))
        self.analog_agc2_xx_0_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5)
        self.analog_agc2_xx_0_0.set_max_gain(65536)
        self.analog_agc2_xx_0 = analog.agc2_cc(decay_rate, decay_rate, 1.0, .5)
        self.analog_agc2_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_argmax_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_max_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_vector_to_stream_1, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_stream_to_vector_1, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_histogram_sink_x_0_0, 0))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_number_sink_0, 1))
        self.connect((self.blocks_max_xx_0, 0), (self.qtgui_time_sink_x_0_0, 1))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_histogram_sink_x_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 2))
        self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.fft_vxx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_short_to_float_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_1, 0), (self.fft_vxx_1, 0))
        self.connect((self.blocks_vector_to_stream_1, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.fft_vxx_1, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.fft_vxx_2, 0), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.low_pass_filter_1, 0), (self.blocks_delay_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.qtgui_freq_sink_x_0_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_1, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.uhd_usrp_source_1, 1), (self.analog_agc2_xx_0_0, 0))
コード例 #24
0
    def __init__(self):
        gr.top_block.__init__(self, "Calibration Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Calibration Example")
        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", "calibration_example_gui")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.speed_of_light = speed_of_light = 299792458
        self.antenna_spacing = antenna_spacing = 0.06
        self.variable_qtgui_chooser_0_1_1 = variable_qtgui_chooser_0_1_1 = 1
        self.variable_qtgui_chooser_0_1_0 = variable_qtgui_chooser_0_1_0 = 1
        self.variable_qtgui_chooser_0_0_0 = variable_qtgui_chooser_0_0_0 = 1
        self.variable_qtgui_chooser_0_0 = variable_qtgui_chooser_0_0 = 0
        self.samp_rate = samp_rate = 100000000/256
        self.gain_rx = gain_rx = 0
        self.center_freq = center_freq = speed_of_light/(2*antenna_spacing)
        self.cal_freq = cal_freq = 1024

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_chooser_0_1_1_options = (1, 0, )
        self._variable_qtgui_chooser_0_1_1_labels = ("Not Started", "Start Save", )
        self._variable_qtgui_chooser_0_1_1_group_box = Qt.QGroupBox("Trigger Data Save")
        self._variable_qtgui_chooser_0_1_1_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._variable_qtgui_chooser_0_1_1_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_1_1_group_box.setLayout(self._variable_qtgui_chooser_0_1_1_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_1_1_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_1_1_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_1_1_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_1_1_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_1_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_1_options.index(i)))
        self._variable_qtgui_chooser_0_1_1_callback(self.variable_qtgui_chooser_0_1_1)
        self._variable_qtgui_chooser_0_1_1_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_1_1(self._variable_qtgui_chooser_0_1_1_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_1_group_box)
        self._variable_qtgui_chooser_0_1_0_options = (1, 0, )
        self._variable_qtgui_chooser_0_1_0_labels = ("Stop", "Running", )
        self._variable_qtgui_chooser_0_1_0_tool_bar = Qt.QToolBar(self)
        self._variable_qtgui_chooser_0_1_0_tool_bar.addWidget(Qt.QLabel("Sync System"+": "))
        self._variable_qtgui_chooser_0_1_0_combo_box = Qt.QComboBox()
        self._variable_qtgui_chooser_0_1_0_tool_bar.addWidget(self._variable_qtgui_chooser_0_1_0_combo_box)
        for label in self._variable_qtgui_chooser_0_1_0_labels: self._variable_qtgui_chooser_0_1_0_combo_box.addItem(label)
        self._variable_qtgui_chooser_0_1_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_0_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_0_options.index(i)))
        self._variable_qtgui_chooser_0_1_0_callback(self.variable_qtgui_chooser_0_1_0)
        self._variable_qtgui_chooser_0_1_0_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_variable_qtgui_chooser_0_1_0(self._variable_qtgui_chooser_0_1_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_0_tool_bar)
        self._variable_qtgui_chooser_0_0_0_options = (0, 1, )
        self._variable_qtgui_chooser_0_0_0_labels = ("Enable", "Disable", )
        self._variable_qtgui_chooser_0_0_0_group_box = Qt.QGroupBox("Transmitter Enable")
        self._variable_qtgui_chooser_0_0_0_box = Qt.QVBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._variable_qtgui_chooser_0_0_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_0_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_0_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_0_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_0_options.index(i)))
        self._variable_qtgui_chooser_0_0_0_callback(self.variable_qtgui_chooser_0_0_0)
        self._variable_qtgui_chooser_0_0_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_0_0(self._variable_qtgui_chooser_0_0_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_0_group_box)
        self._variable_qtgui_chooser_0_0_options = (0, 1, )
        self._variable_qtgui_chooser_0_0_labels = ("Enable", "Disable", )
        self._variable_qtgui_chooser_0_0_group_box = Qt.QGroupBox("Source Enable")
        self._variable_qtgui_chooser_0_0_box = Qt.QVBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._variable_qtgui_chooser_0_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_options.index(i)))
        self._variable_qtgui_chooser_0_0_callback(self.variable_qtgui_chooser_0_0)
        self._variable_qtgui_chooser_0_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_0(self._variable_qtgui_chooser_0_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_group_box)
        self.wifius_find_scale_factor_0_0 = wifius.find_scale_factor(samp_rate,cal_freq)
        self.wifius_find_scale_factor_0 = wifius.find_scale_factor(samp_rate,cal_freq)
        self.wifius_divide_by_message_0_0 = wifius.divide_by_message()
        self.wifius_divide_by_message_0 = wifius.divide_by_message()
        self.wifius_blocker_0 = wifius.blocker(True)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(("addr0=192.168.20.2,addr1=192.168.50.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(2),
        	),
        )
        self.uhd_usrp_source_0_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0_0.set_time_source("external", 0)
        self.uhd_usrp_source_0_0.set_clock_source("external", 1)
        self.uhd_usrp_source_0_0.set_time_source("external", 1)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 0)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 1)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 1)
        self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.90.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0_0_0.set_gain(30, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.40.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_0.set_clock_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_time_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0_0.set_gain(10, 0)
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "Input")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "Post Gain Correct")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Post Phase Correct")
        self.top_layout.addWidget(self.tab)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_1.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(True)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_control_panel(True)
        
        if not True:
          self.qtgui_time_sink_x_1.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate, #samp_rate
        	"", #name
        	2 #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_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(True)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.delay_correct_hier_0 = delay_correct_hier(
            cal_tone_freq=cal_freq,
            mu=0.001,
            samp_rate=samp_rate,
        )
        self.blocks_message_strobe_0_1 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_1_1), 1000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_1_0), 1000)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blks2_valve_0_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0_0))
        self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0))
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.delay_correct_hier_0, 'enable_sync'))    
        self.msg_connect((self.blocks_message_strobe_0_1, 'strobe'), (self.wifius_blocker_0, 'enable_stop'))    
        self.msg_connect((self.wifius_find_scale_factor_0, 'message'), (self.wifius_divide_by_message_0, 'set_divisor'))    
        self.msg_connect((self.wifius_find_scale_factor_0_0, 'message'), (self.wifius_divide_by_message_0_0, 'set_divisor'))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blks2_valve_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_valve_0_0, 0))    
        self.connect((self.blks2_valve_0, 0), (self.uhd_usrp_sink_0_0, 0))    
        self.connect((self.blks2_valve_0_0, 0), (self.uhd_usrp_sink_0_0_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.delay_correct_hier_0, 0), (self.blocks_complex_to_real_1, 0))    
        self.connect((self.delay_correct_hier_0, 1), (self.qtgui_time_sink_x_1, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.wifius_blocker_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.wifius_blocker_0, 1))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.wifius_divide_by_message_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.wifius_divide_by_message_0_0, 0))    
        self.connect((self.wifius_blocker_0, 0), (self.wifius_find_scale_factor_0, 0))    
        self.connect((self.wifius_blocker_0, 1), (self.wifius_find_scale_factor_0_0, 0))    
        self.connect((self.wifius_divide_by_message_0, 0), (self.delay_correct_hier_0, 0))    
        self.connect((self.wifius_divide_by_message_0_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.wifius_divide_by_message_0_0, 0), (self.delay_correct_hier_0, 1))    
コード例 #25
0
ファイル: ArrayTest3.py プロジェクト: Ugikie/PositionControl
    def __init__(self):
        gr.top_block.__init__(self, "Arraytest3")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.gain = gain = 60
        self.center_frequency = center_frequency = 1949.95e6
        self.bandwidth = bandwidth = 100e6

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(('addr=192.168.10.2', 'rx_lo_source=external,init_cals=BASIC|TX_ATTENUATION_DELAY|RX_GAIN_DELAY|PATH_DELAY|TX_LO_LEAKAGE_INTERNAL|LOOPBACK_RX_LO_DELAY')),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(4),
        	),
        )
        self.uhd_usrp_source_0.set_clock_source('internal', 0)
        self.uhd_usrp_source_0.set_subdev_spec("A:0 A:1 B:0 B:1", 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0.set_center_freq(center_frequency, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_bandwidth(bandwidth, 0)
        self.uhd_usrp_source_0.set_center_freq(center_frequency, 1)
        self.uhd_usrp_source_0.set_gain(gain, 1)
        self.uhd_usrp_source_0.set_antenna('RX2', 1)
        self.uhd_usrp_source_0.set_bandwidth(bandwidth, 1)
        self.uhd_usrp_source_0.set_center_freq(center_frequency, 2)
        self.uhd_usrp_source_0.set_gain(gain, 2)
        self.uhd_usrp_source_0.set_antenna('RX2', 2)
        self.uhd_usrp_source_0.set_bandwidth(bandwidth, 2)
        self.uhd_usrp_source_0.set_center_freq(center_frequency, 3)
        self.uhd_usrp_source_0.set_gain(gain, 3)
        self.uhd_usrp_source_0.set_antenna('RX2', 3)
        self.uhd_usrp_source_0.set_bandwidth(bandwidth, 3)
        self.blocks_head_0_1 = blocks.head(gr.sizeof_gr_complex*1, 2000000)
        self.blocks_head_0_0_0 = blocks.head(gr.sizeof_gr_complex*1, 2000000)
        self.blocks_head_0_0 = blocks.head(gr.sizeof_gr_complex*1, 2000000)
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, 2000000)


        #st = datetime.datetime.fromtimestamp(time.time()).strftime('%H:%M:%S')
        degreeIncrements = sys.argv[1]
        dateAndTime = sys.argv[2]
        currentDegree = sys.argv[3]
        if (not os.path.exists('/home/ugikie/Documents/USRP_DATA/Inc_' + degreeIncrements)):
            os.mkdir('/home/ugikie/Documents/USRP_DATA/Inc_' + degreeIncrements)
        if (not os.path.exists('/home/ugikie/Documents/USRP_DATA/Inc_' + degreeIncrements + '/ArrayTest_' + dateAndTime)):
            os.mkdir('/home/ugikie/Documents/USRP_DATA/Inc_' + degreeIncrements + '/ArrayTest_' + dateAndTime)
        self.blocks_file_sink_0_2 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/ugikie/Documents/USRP_DATA/Inc_' + degreeIncrements + '/ArrayTest_' + dateAndTime + '/ArrayTest3_' + currentDegree, False)
        self.blocks_file_sink_0_2.set_unbuffered(False)
        self.blocks_file_sink_0_1 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/ugikie/Documents/USRP_DATA/Inc_' + degreeIncrements + '/ArrayTest_' + dateAndTime + '/ArrayTest0_' + currentDegree, False)
        self.blocks_file_sink_0_1.set_unbuffered(False)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/ugikie/Documents/USRP_DATA/Inc_' + degreeIncrements + '/ArrayTest_' + dateAndTime + '/ArrayTest1_' + currentDegree, False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/ugikie/Documents/USRP_DATA/Inc_' + degreeIncrements + '/ArrayTest_' + dateAndTime + '/ArrayTest2_' + currentDegree, False)
        self.blocks_file_sink_0.set_unbuffered(False)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0_1, 0))
        self.connect((self.blocks_head_0_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_head_0_0_0, 0), (self.blocks_file_sink_0_2, 0))
        self.connect((self.blocks_head_0_1, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_head_0, 0))
        self.connect((self.uhd_usrp_source_0, 1), (self.blocks_head_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 3), (self.blocks_head_0_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 2), (self.blocks_head_0_1, 0))
コード例 #26
0
    def __init__(self):
        gr.top_block.__init__(self, "Fm Channelizer")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Channelizer")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme("gnuradio-grc"))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.synth_channels = synth_channels = 6
        self.channels = channels = 10
        self.ch_rate = ch_rate = 100e3
        self.samp_rate = samp_rate = ch_rate * channels
        self.gain = gain = 20
        self.fm_quad_rate = fm_quad_rate = ch_rate * synth_channels
        self.ch_tb = ch_tb = 20e3
        self.ch_bw = ch_bw = ch_rate / 2
        self.audio_rate = audio_rate = 60e3
        self.atten = atten = 80
        self.volume = volume = 0.1
        self.tun_gain = tun_gain = gain
        self.pfb_taps = pfb_taps = firdes.low_pass_2(1, samp_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS)
        self.pfb_synth_taps = pfb_synth_taps = firdes.low_pass_2(
            channels / 2, synth_channels * ch_rate, ch_bw, ch_tb, atten, firdes.WIN_BLACKMAN_HARRIS
        )
        self.freq_corr = freq_corr = 0
        self.fm_audio_decim = fm_audio_decim = int(fm_quad_rate / audio_rate) * 2
        self.channel = channel = 0
        self.center_freq = center_freq = 101.1e6 + 0e3
        self.address = address = ""

        ##################################################
        # Blocks
        ##################################################
        self._volume_layout = Qt.QVBoxLayout()
        self._volume_tool_bar = Qt.QToolBar(self)
        self._volume_layout.addWidget(self._volume_tool_bar)
        self._volume_tool_bar.addWidget(Qt.QLabel("Volume" + ": "))

        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)

            @pyqtSlot("double")
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)

        self._volume_counter = qwt_counter_pyslot()
        self._volume_counter.setRange(0, 10, 0.1)
        self._volume_counter.setNumButtons(2)
        self._volume_counter.setValue(self.volume)
        self._volume_tool_bar.addWidget(self._volume_counter)
        self._volume_counter.valueChanged.connect(self.set_volume)
        self._volume_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._volume_slider.setRange(0, 10, 0.1)
        self._volume_slider.setValue(self.volume)
        self._volume_slider.setMinimumWidth(200)
        self._volume_slider.valueChanged.connect(self.set_volume)
        self._volume_layout.addWidget(self._volume_slider)
        self.top_grid_layout.addLayout(self._volume_layout, 3, 0, 1, 1)
        self._tun_gain_layout = Qt.QVBoxLayout()
        self._tun_gain_tool_bar = Qt.QToolBar(self)
        self._tun_gain_layout.addWidget(self._tun_gain_tool_bar)
        self._tun_gain_tool_bar.addWidget(Qt.QLabel("Gain (dB)" + ": "))

        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)

            @pyqtSlot("double")
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)

        self._tun_gain_counter = qwt_counter_pyslot()
        self._tun_gain_counter.setRange(0, 70, 1)
        self._tun_gain_counter.setNumButtons(2)
        self._tun_gain_counter.setValue(self.tun_gain)
        self._tun_gain_tool_bar.addWidget(self._tun_gain_counter)
        self._tun_gain_counter.valueChanged.connect(self.set_tun_gain)
        self._tun_gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._tun_gain_slider.setRange(0, 70, 1)
        self._tun_gain_slider.setValue(self.tun_gain)
        self._tun_gain_slider.setMinimumWidth(200)
        self._tun_gain_slider.valueChanged.connect(self.set_tun_gain)
        self._tun_gain_layout.addWidget(self._tun_gain_slider)
        self.top_grid_layout.addLayout(self._tun_gain_layout, 2, 1, 1, 1)
        self._freq_corr_layout = Qt.QVBoxLayout()
        self._freq_corr_tool_bar = Qt.QToolBar(self)
        self._freq_corr_layout.addWidget(self._freq_corr_tool_bar)
        self._freq_corr_tool_bar.addWidget(Qt.QLabel("Frequency Correction" + ": "))

        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)

            @pyqtSlot("double")
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)

        self._freq_corr_counter = qwt_counter_pyslot()
        self._freq_corr_counter.setRange(-40e3, 40e3, 100)
        self._freq_corr_counter.setNumButtons(2)
        self._freq_corr_counter.setValue(self.freq_corr)
        self._freq_corr_tool_bar.addWidget(self._freq_corr_counter)
        self._freq_corr_counter.valueChanged.connect(self.set_freq_corr)
        self._freq_corr_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._freq_corr_slider.setRange(-40e3, 40e3, 100)
        self._freq_corr_slider.setValue(self.freq_corr)
        self._freq_corr_slider.setMinimumWidth(200)
        self._freq_corr_slider.valueChanged.connect(self.set_freq_corr)
        self._freq_corr_layout.addWidget(self._freq_corr_slider)
        self.top_grid_layout.addLayout(self._freq_corr_layout, 3, 1, 1, 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join((address, "")), uhd.stream_args(cpu_format="fc32", channels=range(1))
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(center_freq + freq_corr, 0)
        self.uhd_usrp_source_0.set_gain(tun_gain, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c(
            1024,  # size
            firdes.WIN_FLATTOP,  # wintype
            0,  # fc
            ch_rate * synth_channels,  # bw
            "QT GUI Plot",  # name
            1,  # number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0)

        if complex == type(float()):
            self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True)

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

        self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 1, 1, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  # size
            firdes.WIN_BLACKMAN_hARRIS,  # wintype
            0,  # fc
            samp_rate,  # bw
            "QT GUI Plot",  # name
            1,  # number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)

        if complex == type(float()):
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 2)
        self.pfb_synthesizer_ccf_0 = filter.pfb_synthesizer_ccf(synth_channels, (pfb_synth_taps), True)
        self.pfb_synthesizer_ccf_0.set_channel_map(([10, 11, 0, 1, 2, 3]))
        self.pfb_synthesizer_ccf_0.declare_sample_delay(0)

        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(channels, (pfb_taps), 2.0, atten)
        self.pfb_channelizer_ccf_0.set_channel_map(())
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_fff(
            44.1e3 / (fm_quad_rate / fm_audio_decim), taps=None, flt_size=32
        )
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.fir_filter_xxx_0 = filter.fir_filter_ccc(
            2, (firdes.low_pass_2(1, ch_rate * synth_channels, 250e3, 300e3, 40, firdes.WIN_BLACKMAN_HARRIS))
        )
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self._channel_layout = Qt.QVBoxLayout()
        self._channel_tool_bar = Qt.QToolBar(self)
        self._channel_layout.addWidget(self._channel_tool_bar)
        self._channel_tool_bar.addWidget(Qt.QLabel("Output Channel" + ": "))

        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)

            @pyqtSlot("double")
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)

        self._channel_counter = qwt_counter_pyslot()
        self._channel_counter.setRange(0, channels - 1, 1)
        self._channel_counter.setNumButtons(2)
        self._channel_counter.setValue(self.channel)
        self._channel_tool_bar.addWidget(self._channel_counter)
        self._channel_counter.valueChanged.connect(self.set_channel)
        self._channel_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._channel_slider.setRange(0, channels - 1, 1)
        self._channel_slider.setValue(self.channel)
        self._channel_slider.setMinimumWidth(200)
        self._channel_slider.valueChanged.connect(self.set_channel)
        self._channel_layout.addWidget(self._channel_slider)
        self.top_grid_layout.addLayout(self._channel_layout, 2, 0, 1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx = blocks.multiply_const_vff((volume,))
        self.audio_sink = audio.sink(44100, "", True)
        self.analog_wfm_rcv = analog.wfm_rcv(quad_rate=fm_quad_rate, audio_decimation=fm_audio_decim)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_agc2_xx_0, 0), (self.pfb_channelizer_ccf_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_wfm_rcv, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx, 0), (self.audio_sink, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.analog_wfm_rcv, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx, 0))
        self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0, 0))
        self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 1))
        self.connect((self.pfb_channelizer_ccf_0, 8), (self.blocks_null_sink_0, 2))
        self.connect((self.pfb_channelizer_ccf_0, 9), (self.blocks_null_sink_0, 3))
        self.connect((self.pfb_channelizer_ccf_0, 0), (self.pfb_synthesizer_ccf_0, 0))
        self.connect((self.pfb_channelizer_ccf_0, 1), (self.pfb_synthesizer_ccf_0, 1))
        self.connect((self.pfb_channelizer_ccf_0, 2), (self.pfb_synthesizer_ccf_0, 2))
        self.connect((self.pfb_channelizer_ccf_0, 3), (self.pfb_synthesizer_ccf_0, 3))
        self.connect((self.pfb_channelizer_ccf_0, 4), (self.pfb_synthesizer_ccf_0, 4))
        self.connect((self.pfb_channelizer_ccf_0, 5), (self.pfb_synthesizer_ccf_0, 5))
        self.connect((self.pfb_synthesizer_ccf_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
コード例 #27
0
    def __init__(self):
        gr.top_block.__init__(self, "Play sigMF recordings")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Play sigMF recordings")
        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", "file_play")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.gain = gain = 0
        self.freq = freq = 433.7e6
        self.antenna = antenna = "TX/RX"

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 60, 1, 0, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_win)
        self._freq_range = Range(400e6, 6e9, 100e3, 433.7e6, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Freq', "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_win)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0,1)),
            ),
            '',
        )
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_bandwidth(samp_rate, 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec())
        self.fosphor_qt_sink_c_0_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0_0.set_frequency_range(freq, samp_rate)
        self._fosphor_qt_sink_c_0_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_0_0_win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_file_source_1 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/david/sigMF_ML/RF_SVD/ptt_2_10_svd_1024_fft/ptt_svd5_1024_fft', True, 0, 0)
        self.blocks_file_source_1.set_begin_tag(pmt.PMT_NIL)
        # Create the options list
        self._antenna_options = ("TX/RX", "RX2", )
        # Create the labels list
        self._antenna_labels = ("TX/RX", "RX2", )
        # Create the combo box
        self._antenna_tool_bar = Qt.QToolBar(self)
        self._antenna_tool_bar.addWidget(Qt.QLabel('Antenna' + ": "))
        self._antenna_combo_box = Qt.QComboBox()
        self._antenna_tool_bar.addWidget(self._antenna_combo_box)
        for _label in self._antenna_labels: self._antenna_combo_box.addItem(_label)
        self._antenna_callback = lambda i: Qt.QMetaObject.invokeMethod(self._antenna_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._antenna_options.index(i)))
        self._antenna_callback(self.antenna)
        self._antenna_combo_box.currentIndexChanged.connect(
            lambda i: self.set_antenna(self._antenna_options[i]))
        # Create the radio buttons
        self.top_grid_layout.addWidget(self._antenna_tool_bar)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_1, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_file_source_1, 0), (self.fosphor_qt_sink_c_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.uhd_usrp_sink_0, 0))
コード例 #28
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 40
        self.samp_rate = samp_rate = 20e6
        self.rx_gain = rx_gain = 40
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 2.412e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label='tx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6,10e6, 20e6],
        	labels=["5MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	label='rx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_rx_gain_sizer)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	label='mult',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_sizer)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	labels=['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'],
        )
        self.Add(self._freq_chooser)
        self._encoding_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.encoding,
        	callback=self.set_encoding,
        	label="Encoding",
        	choices=[0,1,2,3,4,5,6,7],
        	labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=5000,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]), ([0x02, 0x11, 0x87, 0xBA, 0x68, 0x3B]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))    
コード例 #29
0
    def __init__(self):
        gr.top_block.__init__(self, "Calibration Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Calibration Example")
        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", "calibration_example_gui")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.antenna_spacing_inches = antenna_spacing_inches = 6.25
        self.speed_of_light = speed_of_light = 299792458
        self.gain_rx_array = gain_rx_array = 3
        self.antenna_spacing = antenna_spacing = antenna_spacing_inches*0.0254
        self.window = window = 1024
        self.variable_qtgui_chooser_0_1_1 = variable_qtgui_chooser_0_1_1 = 1
        self.variable_qtgui_chooser_0_0 = variable_qtgui_chooser_0_0 = 0
        self.sync = sync = pmt.PMT_F
        self.snapshots = snapshots = 4096
        self._samples_to_save_config = ConfigParser.ConfigParser()
        self._samples_to_save_config.read("/home/travis/Dropbox/PHD/WiFiUS/doa/gnuradio/gr-matlab/config.gr")
        try: samples_to_save = self._samples_to_save_config.getfloat("rx", "samples_to_save")
        except: samples_to_save = 2**18
        self.samples_to_save = samples_to_save
        self.samp_rate = samp_rate = 100000000/64
        self.pi = pi = 3.14159265359
        self.phase_c3 = phase_c3 = 0
        self.phase_c2 = phase_c2 = 0
        self.phase_c1 = phase_c1 = 0
        self.phase_c0 = phase_c0 = 0
        self.offset = offset = 0
        self.label2 = label2 = "Check To Enable"
        self.label = label = "Check To Enable"
        self.gain_tx2 = gain_tx2 = 20
        self.gain_tx1 = gain_tx1 = 20
        self.gain_rx = gain_rx = gain_rx_array
        self.distant_tx_target = distant_tx_target = 1
        self.distant_tx = distant_tx = 1
        self.center_freq = center_freq = speed_of_light/(2*antenna_spacing)
        self.cal_freq = cal_freq = 10000
        self.ant_cal_enable = ant_cal_enable = 1

        ##################################################
        # Blocks
        ##################################################
        _variable_qtgui_chooser_0_1_1_check_box = Qt.QCheckBox("Trigger Data Save")
        self._variable_qtgui_chooser_0_1_1_choices = {True: 0, False: 1}
        self._variable_qtgui_chooser_0_1_1_choices_inv = dict((v,k) for k,v in self._variable_qtgui_chooser_0_1_1_choices.iteritems())
        self._variable_qtgui_chooser_0_1_1_callback = lambda i: Qt.QMetaObject.invokeMethod(_variable_qtgui_chooser_0_1_1_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_chooser_0_1_1_choices_inv[i]))
        self._variable_qtgui_chooser_0_1_1_callback(self.variable_qtgui_chooser_0_1_1)
        _variable_qtgui_chooser_0_1_1_check_box.stateChanged.connect(lambda i: self.set_variable_qtgui_chooser_0_1_1(self._variable_qtgui_chooser_0_1_1_choices[bool(i)]))
        self.top_grid_layout.addWidget(_variable_qtgui_chooser_0_1_1_check_box, 4,0)
        _variable_qtgui_chooser_0_0_check_box = Qt.QCheckBox("Connected Sync Tx")
        self._variable_qtgui_chooser_0_0_choices = {True: 0, False: 1}
        self._variable_qtgui_chooser_0_0_choices_inv = dict((v,k) for k,v in self._variable_qtgui_chooser_0_0_choices.iteritems())
        self._variable_qtgui_chooser_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(_variable_qtgui_chooser_0_0_check_box, "setChecked", Qt.Q_ARG("bool", self._variable_qtgui_chooser_0_0_choices_inv[i]))
        self._variable_qtgui_chooser_0_0_callback(self.variable_qtgui_chooser_0_0)
        _variable_qtgui_chooser_0_0_check_box.stateChanged.connect(lambda i: self.set_variable_qtgui_chooser_0_0(self._variable_qtgui_chooser_0_0_choices[bool(i)]))
        self.top_grid_layout.addWidget(_variable_qtgui_chooser_0_0_check_box, 3,0)
        self._phase_c1_range = Range(-180, 180, 1, 0, 200)
        self._phase_c1_win = RangeWidget(self._phase_c1_range, self.set_phase_c1, "Phase Channel1", "counter_slider", float)
        self.top_layout.addWidget(self._phase_c1_win)
        self._phase_c0_range = Range(-180, 180, 1, 0, 200)
        self._phase_c0_win = RangeWidget(self._phase_c0_range, self.set_phase_c0, "Phase Channel0", "counter_slider", float)
        self.top_layout.addWidget(self._phase_c0_win)
        self._gain_tx2_range = Range(0, 30, 1, 20, 200)
        self._gain_tx2_win = RangeWidget(self._gain_tx2_range, self.set_gain_tx2, "Gain DRTX 2", "counter", float)
        self.top_grid_layout.addWidget(self._gain_tx2_win, 4,1)
        self._gain_tx1_range = Range(0, 30, 1, 20, 200)
        self._gain_tx1_win = RangeWidget(self._gain_tx1_range, self.set_gain_tx1, "Gain DRTX 1", "counter", float)
        self.top_grid_layout.addWidget(self._gain_tx1_win, 3,1)
        _distant_tx_target_check_box = Qt.QCheckBox("Distant TX Target")
        self._distant_tx_target_choices = {True: 0, False: 1}
        self._distant_tx_target_choices_inv = dict((v,k) for k,v in self._distant_tx_target_choices.iteritems())
        self._distant_tx_target_callback = lambda i: Qt.QMetaObject.invokeMethod(_distant_tx_target_check_box, "setChecked", Qt.Q_ARG("bool", self._distant_tx_target_choices_inv[i]))
        self._distant_tx_target_callback(self.distant_tx_target)
        _distant_tx_target_check_box.stateChanged.connect(lambda i: self.set_distant_tx_target(self._distant_tx_target_choices[bool(i)]))
        self.top_grid_layout.addWidget(_distant_tx_target_check_box, 2,0)
        _distant_tx_check_box = Qt.QCheckBox("Distant TX Ref")
        self._distant_tx_choices = {True: 0, False: 1}
        self._distant_tx_choices_inv = dict((v,k) for k,v in self._distant_tx_choices.iteritems())
        self._distant_tx_callback = lambda i: Qt.QMetaObject.invokeMethod(_distant_tx_check_box, "setChecked", Qt.Q_ARG("bool", self._distant_tx_choices_inv[i]))
        self._distant_tx_callback(self.distant_tx)
        _distant_tx_check_box.stateChanged.connect(lambda i: self.set_distant_tx(self._distant_tx_choices[bool(i)]))
        self.top_grid_layout.addWidget(_distant_tx_check_box, 1,0)
        self.wifius_gen_music_spectrum_vcvf_0 = wifius.gen_music_spectrum_vcvf(2, 1, -90, 90, 1, 0.5, snapshots)
        self.wifius_antenna_array_calibration_cf_0 = wifius.antenna_array_calibration_cf(90, 0.5, 2, 4096)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(("addr0=192.168.20.2,addr1=192.168.30.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(2),
        	),
        )
        self.uhd_usrp_source_0_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0_0.set_time_source("external", 0)
        self.uhd_usrp_source_0_0.set_clock_source("external", 1)
        self.uhd_usrp_source_0_0.set_time_source("external", 1)
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0_0.set_gain(10, 0)
        self.uhd_usrp_source_0_0.set_antenna("RX2", 0)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 1)
        self.uhd_usrp_source_0_0.set_gain(10, 1)
        self.uhd_usrp_source_0_0.set_antenna("RX2", 1)
        self.target_tx_hier_0_0 = target_tx_hier(
            addr0="addr=192.168.90.2",
            cal_freq=10e3,
            center_freq=center_freq,
            gain_tx2=gain_tx1,
            samp_rate=samp_rate,
            tone_type="Real",
        )
        self.target_tx_hier_0 = target_tx_hier(
            addr0="addr=192.168.80.2",
            cal_freq=10e3,
            center_freq=center_freq,
            gain_tx2=gain_tx2,
            samp_rate=samp_rate,
            tone_type="Real",
        )
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "Input")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "Post Phase Correct")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Angle of Arrival")
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, "MuSIC Spectrum")
        self.top_layout.addWidget(self.tab)
        self.sync_tx_hier_0 = sync_tx_hier(
            addr0="addr=192.168.60.2",
            cal_freq=1e3,
            center_freq=center_freq,
            gain_tx2=10,
            samp_rate=samp_rate,
            tone_type="Complex",
        )
        _sync_check_box = Qt.QCheckBox("Enable Sync Adaption")
        self._sync_choices = {True: pmt.PMT_T, False: pmt.PMT_F}
        self._sync_choices_inv = dict((v,k) for k,v in self._sync_choices.iteritems())
        self._sync_callback = lambda i: Qt.QMetaObject.invokeMethod(_sync_check_box, "setChecked", Qt.Q_ARG("bool", self._sync_choices_inv[i]))
        self._sync_callback(self.sync)
        _sync_check_box.stateChanged.connect(lambda i: self.set_sync(self._sync_choices[bool(i)]))
        self.top_grid_layout.addWidget(_sync_check_box, 1,1)
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            180,
            -90,
            1.0,
            "Offset",
            "dB",
            "MuSIC Spectrum",
            1 # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.10)
        self.qtgui_vector_sink_f_0.set_y_axis(-140, 10)
        self.qtgui_vector_sink_f_0.enable_autoscale(True)
        self.qtgui_vector_sink_f_0.enable_grid(True)
        self.qtgui_vector_sink_f_0.set_x_axis_units("")
        self.qtgui_vector_sink_f_0.set_y_axis_units("")
        self.qtgui_vector_sink_f_0.set_ref_level(0)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_vector_sink_f_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_vector_sink_f_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	2000, #size
        	samp_rate, #samp_rate
        	"", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(True)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self._phase_c3_range = Range(-180, 180, 1, 0, 200)
        self._phase_c3_win = RangeWidget(self._phase_c3_range, self.set_phase_c3, "Phase Channel3", "counter_slider", float)
        self.top_layout.addWidget(self._phase_c3_win)
        self._phase_c2_range = Range(-180, 180, 1, 0, 200)
        self._phase_c2_win = RangeWidget(self._phase_c2_range, self.set_phase_c2, "Phase Channel2", "counter_slider", float)
        self.top_layout.addWidget(self._phase_c2_win)
        self._offset_range = Range(-90, 90, 1, 0, 10)
        self._offset_win = RangeWidget(self._offset_range, self.set_offset, "Bias Angle", "counter", float)
        self.top_grid_layout.addWidget(self._offset_win, 2,1)
        self._label2_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._label2_formatter = None
        else:
          self._label2_formatter = lambda x: x
        
        self._label2_tool_bar.addWidget(Qt.QLabel("Algorithm  Control"+": "))
        self._label2_label = Qt.QLabel(str(self._label2_formatter(self.label2)))
        self._label2_tool_bar.addWidget(self._label2_label)
        self.top_grid_layout.addWidget(self._label2_tool_bar, 0,1)
          
        self._label_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._label_formatter = None
        else:
          self._label_formatter = lambda x: x
        
        self._label_tool_bar.addWidget(Qt.QLabel("Transmitter Control"+": "))
        self._label_label = Qt.QLabel(str(self._label_formatter(self.label)))
        self._label_tool_bar.addWidget(self._label_label)
        self.top_grid_layout.addWidget(self._label_tool_bar, 0,0)
          
        self._gain_rx_array_range = Range(0, 30, 1, 3, 200)
        self._gain_rx_array_win = RangeWidget(self._gain_rx_array_range, self.set_gain_rx_array, "Gain RX Array", "counter", float)
        self.top_grid_layout.addWidget(self._gain_rx_array_win, 5,1)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, snapshots)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, snapshots)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((numpy.exp(-1j*phase_c1*pi/180), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((numpy.exp(-1j*phase_c0*pi/180), ))
        self.blocks_message_strobe_0_2_0 = blocks.message_strobe(pmt.from_double(distant_tx_target), 1000)
        self.blocks_message_strobe_0_2 = blocks.message_strobe(pmt.from_double(distant_tx), 1000)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_1_1), 1000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_0), 1000)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        _ant_cal_enable_check_box = Qt.QCheckBox("Enable Antenna Calibration")
        self._ant_cal_enable_choices = {True: 0, False: 1}
        self._ant_cal_enable_choices_inv = dict((v,k) for k,v in self._ant_cal_enable_choices.iteritems())
        self._ant_cal_enable_callback = lambda i: Qt.QMetaObject.invokeMethod(_ant_cal_enable_check_box, "setChecked", Qt.Q_ARG("bool", self._ant_cal_enable_choices_inv[i]))
        self._ant_cal_enable_callback(self.ant_cal_enable)
        _ant_cal_enable_check_box.stateChanged.connect(lambda i: self.set_ant_cal_enable(self._ant_cal_enable_choices[bool(i)]))
        self.top_grid_layout.addWidget(_ant_cal_enable_check_box, 1,4)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.sync_tx_hier_0, 'Trigger'))    
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.wifius_antenna_array_calibration_cf_0, 'enable_hold'))    
        self.msg_connect((self.blocks_message_strobe_0_2, 'strobe'), (self.target_tx_hier_0, 'Trigger'))    
        self.msg_connect((self.blocks_message_strobe_0_2_0, 'strobe'), (self.target_tx_hier_0_0, 'Trigger'))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_stream_to_vector_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wifius_antenna_array_calibration_cf_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_real_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_stream_to_vector_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.wifius_antenna_array_calibration_cf_0, 1))    
        self.connect((self.blocks_stream_to_vector_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 2))    
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 3))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.wifius_antenna_array_calibration_cf_0, 0), (self.wifius_gen_music_spectrum_vcvf_0, 0))    
        self.connect((self.wifius_antenna_array_calibration_cf_0, 1), (self.wifius_gen_music_spectrum_vcvf_0, 1))    
        self.connect((self.wifius_gen_music_spectrum_vcvf_0, 0), (self.qtgui_vector_sink_f_0, 0))    
コード例 #30
0
    def __init__(self):
        gr.top_block.__init__(self, "Calibration Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Calibration Example")
        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", "calibration_example_gui_2x_view")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.speed_of_light = speed_of_light = 299792458
        self.antenna_spacing = antenna_spacing = 0.061
        self.sync = sync = pmt.PMT_F
        self.samp_rate = samp_rate = 100000000/64
        self.gain_rx = gain_rx = 0
        self.center_freq = center_freq = speed_of_light/(2*antenna_spacing)
        self.cal_freq = cal_freq = 1024
        self.Shift = Shift = -4

        ##################################################
        # Blocks
        ##################################################
        self._sync_options = (pmt.PMT_F, pmt.PMT_T, )
        self._sync_labels = ("Stop", "Running", )
        self._sync_group_box = Qt.QGroupBox("Sync System")
        self._sync_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._sync_button_group = variable_chooser_button_group()
        self._sync_group_box.setLayout(self._sync_box)
        for i, label in enumerate(self._sync_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._sync_box.addWidget(radio_button)
        	self._sync_button_group.addButton(radio_button, i)
        self._sync_callback = lambda i: Qt.QMetaObject.invokeMethod(self._sync_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._sync_options.index(i)))
        self._sync_callback(self.sync)
        self._sync_button_group.buttonClicked[int].connect(
        	lambda i: self.set_sync(self._sync_options[i]))
        self.top_layout.addWidget(self._sync_group_box)
        self.uhd_usrp_source_0_0_0 = uhd.usrp_source(
        	",".join(("addr0=192.168.70.2,addr1=192.168.20.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(2),
        	),
        )
        self.uhd_usrp_source_0_0_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0_0_0.set_time_source("external", 0)
        self.uhd_usrp_source_0_0_0.set_clock_source("external", 1)
        self.uhd_usrp_source_0_0_0.set_time_source("external", 1)
        self.uhd_usrp_source_0_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0_0_0.set_gain(gain_rx, 0)
        self.uhd_usrp_source_0_0_0.set_center_freq(center_freq, 1)
        self.uhd_usrp_source_0_0_0.set_gain(gain_rx, 1)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.80.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_0.set_clock_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_time_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0_0.set_gain(10, 0)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	1526*2, #size
        	samp_rate, #samp_rate
        	"", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_control_panel(True)
        
        if not True:
          self.qtgui_time_sink_x_0_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.phase_corrector_0 = phase_corrector(
            window=1024,
        )
        self.blocks_message_strobe_0 = blocks.message_strobe(sync, 1000)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 0)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0)
        self._Shift_range = Range(-4, 4, 0.01, -4, 200)
        self._Shift_win = RangeWidget(self._Shift_range, self.set_Shift, "Shift", "counter_slider", float)
        self.top_layout.addWidget(self._Shift_win)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.phase_corrector_0, 'in'))    
        self.connect((self.analog_sig_source_x_0, 0), (self.uhd_usrp_sink_0_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0_0, 0))    
        self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0_0, 1))    
        self.connect((self.blocks_delay_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.phase_corrector_0, 0), (self.blocks_complex_to_real_1, 0))    
        self.connect((self.uhd_usrp_source_0_0_0, 0), (self.blocks_delay_0, 0))    
        self.connect((self.uhd_usrp_source_0_0_0, 0), (self.phase_corrector_0, 0))    
        self.connect((self.uhd_usrp_source_0_0_0, 1), (self.phase_corrector_0, 1))    
コード例 #31
0
ファイル: uhd_app.py プロジェクト: Stefan-Olt/gnuradio
 def setup_usrp(self, ctor, args, cpu_format='fc32'):
     """
     Instantiate a USRP object; takes care of all kinds of corner cases and settings.
     Pop it and some args onto the class that calls this.
     """
     self.channels = args.channels
     self.cpu_format = cpu_format
     # Create a UHD device object:
     self.usrp = ctor(
         device_addr=args.args,
         stream_args=uhd.stream_args(
             cpu_format,
             args.otw_format,
             args=args.stream_args,
             channels=self.channels,
         )
     )
     # Set the subdevice spec:
     self.spec = self.normalize_sel("mboards", "subdev",
                                    self.usrp.get_num_mboards(), args.spec)
     if self.spec:
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.set_subdev_spec(self.spec[mb_idx], mb_idx)
     # Set the clock and/or time source:
     if args.clock_source is not None:
         self.clock_source = self.normalize_sel("mboards", "clock-source",
                                                self.usrp.get_num_mboards(), args.clock_source)
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.set_clock_source(self.clock_source[mb_idx], mb_idx)
     if args.time_source is not None:
         self.time_source = self.normalize_sel("mboards", "time-source",
                                               self.usrp.get_num_mboards(), args.time_source)
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.set_time_source(self.time_source[mb_idx], mb_idx)
     # Sampling rate:
     self.usrp.set_samp_rate(args.samp_rate)
     self.samp_rate = self.usrp.get_samp_rate()
     self.vprint("Using sampling rate: {rate}".format(rate=self.samp_rate))
     # Set the antenna:
     self.antenna = self.normalize_sel("channels", "antenna", len(args.channels), args.antenna)
     if self.antenna is not None:
         for i, chan in enumerate(self.channels):
             if not self.antenna[i] in self.usrp.get_antennas(i):
                 print("[ERROR] {} is not a valid antenna name for this USRP device!".format(self.antenna[i]))
                 exit(1)
             self.usrp.set_antenna(self.antenna[i], i)
             self.vprint("[{prefix}] Channel {chan}: Using antenna {ant}.".format(
                 prefix=self.prefix, chan=chan, ant=self.usrp.get_antenna(i)
             ))
     self.antenna = self.usrp.get_antenna(0)
     # Set receive daughterboard gain:
     self.set_gain(args.gain)
     self.gain_range = self.usrp.get_gain_range(0)
     # Set frequency (tune request takes lo_offset):
     if hasattr(args, 'lo_offset') and args.lo_offset is not None:
         treq = uhd.tune_request(args.freq, args.lo_offset)
     else:
         treq = uhd.tune_request(args.freq)
     self.has_lo_sensor = 'lo_locked' in self.usrp.get_sensor_names()
     # Set LO export and LO source operation
     if (args.lo_export is not None) and (args.lo_source is not None):
         self.lo_source = self.normalize_sel("channels", "lo-source", len(self.channels), args.lo_source)
         self.lo_export = self.normalize_sel("channels", "lo-export", len(self.channels), args.lo_export)
         for chan, lo_source, lo_export in zip(self.channels, self.lo_source, self.lo_export):
             if (lo_source == "None") or (lo_export == "None"):
                 continue
             if lo_export == "True":
                 #If channel is LO source set frequency and store response
                 self.usrp.set_lo_export_enabled(True, uhd.ALL_LOS, chan)
             if lo_source == "internal":
                 self.lo_source_channel = chan
                 tune_resp = self.usrp.set_center_freq(treq,chan)
             self.usrp.set_lo_source(lo_source, uhd.ALL_LOS,chan)
         # Use lo source tune response to tune dsp_freq on remaining channels
         if getattr(args, 'lo_offset', None) is not None:
             treq = uhd.tune_request(target_freq=args.freq, rf_freq=args.freq+args.lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL,
                                     dsp_freq=tune_resp.actual_dsp_freq,
                                     dsp_freq_policy=uhd.tune_request.POLICY_MANUAL)
         else:
             treq = uhd.tune_request(target_freq=args.freq, rf_freq=args.freg, rf_freq_policy=uhd.tune_request.POLICY_MANUAL,
                                     dsp_freq=tune_resp.actual_dsp_freq,
                                     dsp_freq_policy=uhd.tune_request.POLICY_MANUAL)
         for chan in args.channels:
             if chan == self.lo_source_channel:
                 continue
             self.usrp.set_center_freq(treq,chan)
     # Make sure tuning is synched:
     command_time_set = False
     if len(self.channels) > 1:
         if args.sync == 'pps':
             self.usrp.set_time_unknown_pps(uhd.time_spec())
         cmd_time = self.usrp.get_time_now() + uhd.time_spec(COMMAND_DELAY)
         try:
             for mb_idx in xrange(self.usrp.get_num_mboards()):
                 self.usrp.set_command_time(cmd_time, mb_idx)
             command_time_set = True
         except RuntimeError:
             sys.stderr.write('[{prefix}] [WARNING] Failed to set command times.\n'.format(prefix=self.prefix))
     for i, chan in enumerate(self.channels):
         self.tr = self.usrp.set_center_freq(treq, i)
         if self.tr == None:
             sys.stderr.write('[{prefix}] [ERROR] Failed to set center frequency on channel {chan}\n'.format(
                 prefix=self.prefix, chan=chan
             ))
             exit(1)
     if command_time_set:
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.clear_command_time(mb_idx)
         self.vprint("Syncing channels...".format(prefix=self.prefix))
         time.sleep(COMMAND_DELAY)
     self.freq = self.usrp.get_center_freq(0)
     if args.show_async_msg:
         self.async_msgq = gr.msg_queue(0)
         self.async_src = uhd.amsg_source("", self.async_msgq)
         self.async_rcv = gru.msgq_runner(self.async_msgq, self.async_callback)
コード例 #32
0
ファイル: uhd_app.py プロジェクト: sgardner340/gnuradio
 def setup_usrp(self, ctor, args, cpu_format='fc32'):
     """
     Instantiate a USRP object; takes care of all kinds of corner cases and settings.
     Pop it and some args onto the class that calls this.
     """
     self.channels = args.channels
     self.cpu_format = cpu_format
     # Create a UHD device object:
     self.usrp = ctor(
         device_addr=args.args,
         stream_args=uhd.stream_args(
             cpu_format,
             args.otw_format,
             args=args.stream_args,
             channels=self.channels,
         )
     )
     # Set the subdevice spec:
     if args.spec:
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.set_subdev_spec(args.spec, mb_idx)
     # Sampling rate:
     self.usrp.set_samp_rate(args.samp_rate)
     self.samp_rate = self.usrp.get_samp_rate()
     self.vprint("Using sampling rate: {rate}".format(rate=self.samp_rate))
     # Set the antenna:
     self.antenna = self.normalize_antenna_sel(args)
     if self.antenna is not None:
         for i, chan in enumerate(self.channels):
             if not self.antenna[i] in self.usrp.get_antennas(chan):
                 self.vprint("[ERROR] {} is not a valid antenna name for this USRP device!".format(ant))
                 exit(1)
             self.usrp.set_antenna(self.antenna[i], chan)
             self.vprint("[{prefix}] Channel {chan}: Using antenna {ant}.".format(
                 prefix=self.prefix, chan=chan, ant=self.usrp.get_antenna(chan)
             ))
     self.antenna = self.usrp.get_antenna(self.channels[0])
     # Set receive daughterboard gain:
     self.set_gain(args.gain)
     self.gain_range = self.usrp.get_gain_range(self.channels[0])
     # Set frequency (tune request takes lo_offset):
     if hasattr(args, 'lo_offset') and args.lo_offset is not None:
         treq = uhd.tune_request(args.freq, args.lo_offset)
     else:
         treq = uhd.tune_request(args.freq)
     self.has_lo_sensor = 'lo_locked' in self.usrp.get_sensor_names()
     # Make sure tuning is synched:
     if len(self.channels) > 1:
         if args.sync == 'pps':
             self.usrp.set_time_unknown_pps(uhd.time_spec())
         cmd_time = self.usrp.get_time_now() + uhd.time_spec(COMMAND_DELAY)
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.set_command_time(cmd_time, mb_idx)
     for chan in self.channels:
         self.tr = self.usrp.set_center_freq(treq, chan)
         if self.tr == None:
             sys.stderr.write('[{prefix}] [ERROR] Failed to set center frequency on channel {chan}\n'.format(
                 prefix=self.prefix, chan=chan
             ))
             exit(1)
     if len(self.channels) > 1:
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.clear_command_time(mb_idx)
         self.vprint("Syncing channels...".format(prefix=self.prefix))
         time.sleep(COMMAND_DELAY)
     self.freq = self.usrp.get_center_freq(self.channels[0])
     if args.show_async_msg:
         self.async_msgq = gr.msg_queue(0)
         self.async_src = uhd.amsg_source("", self.async_msgq)
         self.async_rcv = gru.msgq_runner(self.async_msgq, self.async_callback)
コード例 #33
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 50
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 34
        self.timing_loop_bw = timing_loop_bw = 6.28 / 100.0
        self.time_offset = time_offset = 1.00
        self.taps_channel_model = taps_channel_model = [1.0]
        self.samp_rate = samp_rate = 250000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 11 * sps * nfilts)

        self.qpsk = qpsk = digital.constellation_qpsk().base()

        self.phase_bw = phase_bw = 6.28 / 100.0
        self.noise_volt = noise_volt = 0.0000
        self.frequencia_usrp = frequencia_usrp = 1000000000
        self.freq_offset = freq_offset = 0
        self.excess_bw = excess_bw = 0.35
        self.eq_gain = eq_gain = 0.01
        self.documentacao = documentacao = "1010010011110010"
        self.barker_code_13 = barker_code_13 = "1111100110101"
        self.arity = arity = 4

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 50, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0,
                                       3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._variable_qtgui_range_0_range = Range(0, 90, 1, 34, 200)
        self._variable_qtgui_range_0_win = RangeWidget(
            self._variable_qtgui_range_0_range,
            self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_win, 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._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 6.28 / 100.0, 200)
        self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range,
                                               self.set_timing_loop_bw,
                                               'Time: BW', "slider", float)
        self.top_grid_layout.addWidget(self._timing_loop_bw_win, 6, 3, 1, 1)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._samp_rate_range = Range(0, 10000000, 1, 250000, 200)
        self._samp_rate_win = RangeWidget(self._samp_rate_range,
                                          self.set_samp_rate, 'samp_rate',
                                          "counter_slider", int)
        self.top_grid_layout.addWidget(self._samp_rate_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._phase_bw_range = Range(0.0, 1.0, 0.01, 6.28 / 100.0, 200)
        self._phase_bw_win = RangeWidget(self._phase_bw_range,
                                         self.set_phase_bw, 'Phase: Bandwidth',
                                         "dial", float)
        self.top_grid_layout.addWidget(self._phase_bw_win, 6, 1, 1, 1)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._eq_gain_range = Range(0.0, 0.1, 0.001, 0.01, 200)
        self._eq_gain_win = RangeWidget(self._eq_gain_range, self.set_eq_gain,
                                        'Equalizer: rate (Gain)', "slider",
                                        float)
        self.top_grid_layout.addWidget(self._eq_gain_win, 6, 2, 1, 1)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("serial=F5EAC0", "master_clock_rate=32e6")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAE1", "master_clock_rate=32e6")),
            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_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self._time_offset_range = Range(0.999, 1.001, 0.0001, 1.00, 200)
        self._time_offset_win = RangeWidget(self._time_offset_range,
                                            self.set_time_offset,
                                            'Timing Offset', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._time_offset_win, 3, 3, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_FLATTOP,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Frequencia Tratado",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_0_0_0_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0_0_0_0_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_0_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_0_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(
            self._qtgui_freq_sink_x_0_0_0_0_0_0_0_win, 1, 7, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(7, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0_0_0_0_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_FLATTOP,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Phase Tratado",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0_0_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0_0_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_0_0_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0_0_0_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_0_0_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0_0_0_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_0_0_0_win,
                                       1, 5, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 6):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0_0_0_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_FLATTOP,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Error Tratado",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_0_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0_0_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_0_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0_0_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_0_0_win,
                                       1, 6, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_FLATTOP,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Recebido Tratado - Constelation Rec",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_0_win, 1,
                                       4, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_FLATTOP,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Recebido Tratado",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                      0.0, 0, "")
        self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 3,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Recebido",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(False)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

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

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [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, 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.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "Enviado",  #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 True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 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.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            '"Recebido Tratado - Constelation Rec""',  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 2,
                                       4, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "Recebido Tratado",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       3, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "Recebido",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 2, 2,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "Enviado",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

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

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 2, 1, 1,
                                       1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._noise_volt_range = Range(0, 1, 0.01, 0.0000, 200)
        self._noise_volt_win = RangeWidget(self._noise_volt_range,
                                           self.set_noise_volt,
                                           'Noise Voltage', "slider", float)
        self.top_grid_layout.addWidget(self._noise_volt_win, 3, 1, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._freq_offset_range = Range(-0.1, 0.1, 0.001, 0, 200)
        self._freq_offset_win = RangeWidget(self._freq_offset_range,
                                            self.set_freq_offset,
                                            'Frequency Offset',
                                            "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win, 3, 2, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            phase_bw, arity, False)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=qpsk,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=excess_bw,
            verbose=False,
            log=False,
        )
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            qpsk)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, eq_gain, 2)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate,
                                                 True)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            2, 8, "", False, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_file_source_0_0_0_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/andre/Desktop/video2.mpeg', False)
        self.blocks_file_source_0_0_0_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_1_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/andre/Desktop/transmitido/depois.mpeg',
            False)
        self.blocks_file_sink_0_1_0.set_unbuffered(False)
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(
            grc_blks2.packet_encoder(
                samples_per_symbol=sps,
                bits_per_symbol=2,
                preamble='',
                access_code='',
                pad_for_usrp=True,
            ),
            payload_length=0,
        )
        self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(
            grc_blks2.packet_decoder(
                access_code=
                "1010110011011101101001001110001011110010100011000010000011111100",
                threshold=-1,
                callback=lambda ok, payload: self.blks2_packet_decoder_0.
                recv_pkt(ok, payload),
            ), )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_packet_decoder_0, 0),
                     (self.blocks_file_sink_0_1_0, 0))
        self.connect((self.blks2_packet_encoder_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_file_source_0_0_0_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.blks2_packet_decoder_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blks2_packet_encoder_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.qtgui_freq_sink_x_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
コード例 #34
0
    def __init__(self,
                 alpha=0.5,
                 center_freq=3560e6,
                 gain=20,
                 index=0,
                 samp_rate=24e6):
        gr.top_block.__init__(self, "Spread Spectrum Rx")

        ##################################################
        # Parameters
        ##################################################
        self.alpha = alpha
        self.center_freq = center_freq
        self.gain = gain
        self.index = index
        self.samp_rate = samp_rate

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )
        self.uhd_usrp_source_0.set_clock_source('external', 0)
        self.uhd_usrp_source_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, samp_rate, samp_rate, alpha, 64))
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(
            1, [
                1, -1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1,
                -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1,
                1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1,
                -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1,
                1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1,
                -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1,
                -1, -1, 1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1,
                1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 1, -1,
                1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, 1,
                1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, -1,
                1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1,
                -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1,
                1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1,
                -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1,
                1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1,
                -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1,
                -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1,
                -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1,
                -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, 1,
                -1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1,
                -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1,
                1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1,
                -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, -1, -1, 1, 1,
                -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1,
                -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1,
                -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1,
                -1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1,
                1, -1, -1, -1, 1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 1, 1,
                1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1,
                -1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1,
                1, -1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1, 1,
                1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, 1, -1,
                1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1,
                -1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1,
                1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, 1, -1, 1, 1,
                1, 1, -1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1,
                1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, 1, -1,
                1, 1, -1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1,
                1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1,
                -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, -1,
                -1, 1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1,
                -1, 1, -1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, 1, -1,
                -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1,
                1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1,
                -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1,
                -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, -1,
                -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1,
                -1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1,
                1, 1, 1, 1, -1, -1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1,
                -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1,
                -1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, -1, 1,
                -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1,
                -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1,
                1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1,
                -1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1,
                -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1,
                -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1,
                -1, -1
            ])
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   'CIR', False)
        self.blocks_file_sink_1.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fir_filter_xxx_0_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.fir_filter_xxx_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
コード例 #35
0
ファイル: pcal_rec.py プロジェクト: jvierine/phasecal
u.set_clock_source("external", 0)
u.set_time_source("external", 0)

u.set_subdev_spec("A:AB", 0)
u.set_samp_rate(op.samplerate)

u.set_auto_dc_offset(False,0)


tt = time.time()
while tt-math.floor(tt) < 0.2 or tt-math.floor(tt) > 0.3:
    tt = time.time()
    time.sleep(0.01)
print("Latching at "+str(tt))
print(tt)
u.set_time_unknown_pps(uhd.time_spec(math.ceil(tt)+1.0))

op.starttime = math.ceil(time.time())+5
op.starttime = sampler_util.find_next(op.starttime,1)

u.set_start_time(uhd.time_spec(op.starttime))

fg = gr.top_block()
dst = []

win_len = op.window_len
window = numpy.array(numpy.real(scipy.signal.blackmanharris(win_len)),dtype=numpy.float64)
window.tofile("/data/phasecal/coeffs.bin")

# two channel decimating all double precision digital down converter
# with user defined filter coefficients.
コード例 #36
0
    def __init__(self):
        gr.top_block.__init__(self, "Traffic Monitor")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 90
        self.samp_rate = samp_rate = 2 * 10e5
        self.rx_gain = rx_gain = 50
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5.89e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0 = wifi_phy_hier(encoding=0, )
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq - lo_offset, lo_offset), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(
            uhd.tune_request(freq - lo_offset, lo_offset), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(
            False, True)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(
            ([0x30, 0x30, 0x30, 0x30, 0x30, 0x30]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]),
            ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]))
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 0, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        # self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        #self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("     Laptop3     "), 100)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)
        #Add  by Xuepeng Xu
        self.controller = Controller(self)
        self.transmitter = DsrcServer(controller=self.controller)
        #self.message_generator = message_generator()
        #self.message_collector = message_collector()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect(self.transmitter, 'received out',
                         self.ieee802_11_ofdm_mac_0, 'app in')
        #self.msg_connect((self.transmitter,'received out'), (self.blocks_message_strobe_0, 'set_msg'))
        #self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in'))
        self.msg_connect(self.ieee802_11_ofdm_mac_0, 'app out',
                         self.transmitter, 'send in')
        #self.msg_connect((self.ieee802_11_ofdm_mac_0, 'app out'),(self.message_collector, 'message_stream in'))
        #self.msg_connect((self.message_collector,'message_to_collect out'),(self.transmitter,'send in'))
        self.msg_connect(self.ieee802_11_ofdm_mac_0, 'phy out',
                         self.foo_wireshark_connector_0, 'in')
        self.msg_connect(self.ieee802_11_ofdm_mac_0, 'phy out',
                         self.wifi_phy_hier_0, 'mac_in')
        self.msg_connect(self.wifi_phy_hier_0, 'mac_out',
                         self.foo_wireshark_connector_0, 'in')
        self.msg_connect(self.wifi_phy_hier_0, 'mac_out',
                         self.ieee802_11_ofdm_mac_0, 'phy in')
        self.msg_connect(self.wifi_phy_hier_0, 'mac_out',
                         self.ieee802_11_ofdm_parse_mac_0, 'in')
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        #self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0))

        self.controller.start()
コード例 #37
0
ファイル: uhd_app.py プロジェクト: sgardner340/gnuradio
 def setup_usrp(self, ctor, args, cpu_format='fc32'):
     """
     Instantiate a USRP object; takes care of all kinds of corner cases and settings.
     Pop it and some args onto the class that calls this.
     """
     self.channels = args.channels
     self.cpu_format = cpu_format
     # Create a UHD device object:
     self.usrp = ctor(device_addr=args.args,
                      stream_args=uhd.stream_args(
                          cpu_format,
                          args.otw_format,
                          args=args.stream_args,
                          channels=self.channels,
                      ))
     # Set the subdevice spec:
     if args.spec:
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.set_subdev_spec(args.spec, mb_idx)
     # Sampling rate:
     self.usrp.set_samp_rate(args.samp_rate)
     self.samp_rate = self.usrp.get_samp_rate()
     self.vprint("Using sampling rate: {rate}".format(rate=self.samp_rate))
     # Set the antenna:
     self.antenna = self.normalize_antenna_sel(args)
     if self.antenna is not None:
         for i, chan in enumerate(self.channels):
             if not self.antenna[i] in self.usrp.get_antennas(chan):
                 self.vprint(
                     "[ERROR] {} is not a valid antenna name for this USRP device!"
                     .format(ant))
                 exit(1)
             self.usrp.set_antenna(self.antenna[i], chan)
             self.vprint(
                 "[{prefix}] Channel {chan}: Using antenna {ant}.".format(
                     prefix=self.prefix,
                     chan=chan,
                     ant=self.usrp.get_antenna(chan)))
     self.antenna = self.usrp.get_antenna(self.channels[0])
     # Set receive daughterboard gain:
     self.set_gain(args.gain)
     self.gain_range = self.usrp.get_gain_range(self.channels[0])
     # Set frequency (tune request takes lo_offset):
     if hasattr(args, 'lo_offset') and args.lo_offset is not None:
         treq = uhd.tune_request(args.freq, args.lo_offset)
     else:
         treq = uhd.tune_request(args.freq)
     self.has_lo_sensor = 'lo_locked' in self.usrp.get_sensor_names()
     # Make sure tuning is synched:
     if len(self.channels) > 1:
         if args.sync == 'pps':
             self.usrp.set_time_unknown_pps(uhd.time_spec())
         cmd_time = self.usrp.get_time_now() + uhd.time_spec(COMMAND_DELAY)
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.set_command_time(cmd_time, mb_idx)
     for chan in self.channels:
         self.tr = self.usrp.set_center_freq(treq, chan)
         if self.tr == None:
             sys.stderr.write(
                 '[{prefix}] [ERROR] Failed to set center frequency on channel {chan}\n'
                 .format(prefix=self.prefix, chan=chan))
             exit(1)
     if len(self.channels) > 1:
         for mb_idx in xrange(self.usrp.get_num_mboards()):
             self.usrp.clear_command_time(mb_idx)
         self.vprint("Syncing channels...".format(prefix=self.prefix))
         time.sleep(COMMAND_DELAY)
     self.freq = self.usrp.get_center_freq(self.channels[0])
     if args.show_async_msg:
         self.async_msgq = gr.msg_queue(0)
         self.async_src = uhd.amsg_source("", self.async_msgq)
         self.async_rcv = gru.msgq_runner(self.async_msgq,
                                          self.async_callback)
コード例 #38
0
ファイル: radio.py プロジェクト: paulyc/gr-air-modes
    def _setup_source(self, options):
        if options.source == "uhd":
            #UHD source by default
            from gnuradio import uhd
            self._u = uhd.single_usrp_source(options.args,
                                             uhd.io_type_t.COMPLEX_FLOAT32, 1)

            if (options.subdev):
                self._u.set_subdev_spec(options.subdev, 0)

            if not self._u.set_center_freq(options.freq):
                print "Failed to set initial frequency"

            # LimeSDR Mini insists we set sample rate before setting time
            self._u.set_samp_rate(options.rate)
            options.rate = int(self._u.get_samp_rate())  #retrieve actual

            #check for GPSDO
            #if you have a GPSDO, UHD will automatically set the timestamp to UTC time
            #as well as automatically set the clock to lock to GPSDO.
            if self._u.get_time_source(0) != 'gpsdo':
                self._u.set_time_now(uhd.time_spec(0.0))

            if options.antenna is not None:
                self._u.set_antenna(options.antenna)

            if options.gain is None:  #set to halfway
                g = self._u.get_gain_range()
                options.gain = (g.start() + g.stop()) / 2.0

            print "Setting gain to %i" % options.gain
            self._u.set_gain(options.gain)
            print "Gain is %i" % self._u.get_gain()

        #TODO: detect if you're using an RTLSDR or Jawbreaker
        #and set up accordingly.
        elif options.source == "osmocom":  #RTLSDR dongle or HackRF Jawbreaker
            import osmosdr
            self._u = osmosdr.source(options.args)
            #        self._u.set_sample_rate(3.2e6) #fixed for RTL dongles
            self._u.set_sample_rate(options.rate)
            if not self._u.set_center_freq(options.freq):
                print "Failed to set initial frequency"

#        self._u.set_gain_mode(0) #manual gain mode
            if options.gain is None:
                options.gain = 34
            self._u.set_gain(options.gain)
            print "Gain is %i" % self._u.get_gain()

            #Note: this should only come into play if using an RTLSDR.


#        lpfiltcoeffs = gr.firdes.low_pass(1, 5*3.2e6, 1.6e6, 300e3)
#        self._resample = filter.rational_resampler_ccf(interpolation=5, decimation=4, taps=lpfiltcoeffs)

        else:
            #semantically detect whether it's ip.ip.ip.ip:port or filename
            if ':' in options.source:
                try:
                    ip, port = re.search("(.*)\:(\d{1,5})",
                                         options.source).groups()
                except:
                    raise Exception(
                        "Please input UDP source e.g. 192.168.10.1:12345")
                self._u = blocks.udp_source(gr.sizeof_gr_complex, ip,
                                            int(port))
                print "Using UDP source %s:%s" % (ip, port)
            else:
                self._u = blocks.file_source(gr.sizeof_gr_complex,
                                             options.source)
                print "Using file source %s" % options.source

        print "Rate is %i" % (options.rate, )
コード例 #39
0
    def __init__(self,
                 parameter_0="addr=192.168.10.2",
                 parameter_1="addr=192.168.10.3"):
        gr.top_block.__init__(self, "BPSK_radios")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("BPSK_radios")
        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", "BPSK_radios")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.parameter_0 = parameter_0
        self.parameter_1 = parameter_1

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.variable_qtgui_range_0 = variable_qtgui_range_0 = 630e-3
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts)
        self.freq = freq = 2e9
        self.bw = bw = 5e6
        self.Tx_Gain = Tx_Gain = 3
        self.Rx_Gain = Rx_Gain = 30

        ##################################################
        # Blocks
        ##################################################
        self.vocoder_alaw_encode_sb_0 = vocoder.alaw_encode_sb()
        self.vocoder_alaw_decode_bs_0 = vocoder.alaw_decode_bs()
        self._variable_qtgui_range_0_range = Range(0, 1, 1, 630e-3, 200)
        self._variable_qtgui_range_0_win = RangeWidget(
            self._variable_qtgui_range_0_range,
            self.set_variable_qtgui_range_0, "variable_qtgui_range_0",
            "counter_slider", float)
        self.top_layout.addWidget(self._variable_qtgui_range_0_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("addr=192.168.10.3", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate * 10)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(Rx_Gain, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_source_0.set_bandwidth(bw / 5, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate * 10)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(Tx_Gain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0.set_bandwidth(bw / 5, 0)
        self.qtgui_sink_x_1 = qtgui.sink_f(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq,  #fc
            samp_rate,  #bw
            "Recieved signal",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_1.set_update_time(1.0 / 5)
        self._qtgui_sink_x_1_win = sip.wrapinstance(
            self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_1_win)

        self.qtgui_sink_x_1.enable_rf_freq(False)

        self.qtgui_sink_x_0 = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_KAISER,  #wintype
            freq,  #fc
            samp_rate,  #bw
            "Modulator output",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True,  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_sink_x_0_win)

        self.qtgui_sink_x_0.enable_rf_freq(True)

        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("BER")

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

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(
            8, (filter.firdes.root_raised_cosine(8, 8, 1.0, 0.5, 22)))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0)
        self.digital_simple_framer_0 = digital.simple_framer(20)
        self.digital_simple_correlator_0 = digital.simple_correlator(20)
        self.digital_psk_mod_0 = digital.psk.psk_mod(
            constellation_points=2,
            mod_code="gray",
            differential=False,
            samples_per_symbol=4,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_psk_demod_0 = digital.psk.psk_demod(
            constellation_points=2,
            differential=False,
            samples_per_symbol=4,
            excess_bw=0.35,
            phase_bw=6.28 / 100.0,
            timing_bw=6.28 / 100.0,
            mod_code="gray",
            verbose=False,
            log=False,
        )
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            "/home/ettus/Música/bensound-photoalbum.wav", True)
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            "testBPSK_sonido.wav", 1, 44100, 16)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_multiply_const_vxx_4 = blocks.multiply_const_vcc((2, ))
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vff(
            (30.5176e-6, ))
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((2, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc(
            (630e-3, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (32.768e3, ))
        self.blocks_float_to_short_0 = blocks.float_to_short(1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.audio_sink_0 = audio.sink(44100, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.qtgui_sink_x_1, 0))
        self.connect((self.blocks_float_to_short_0, 0),
                     (self.vocoder_alaw_encode_sb_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_float_to_short_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_3, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_const_vxx_4, 0),
                     (self.digital_psk_demod_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_psk_demod_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_psk_demod_0, 0), (self.fec_ber_bf_0, 1))
        self.connect((self.digital_psk_mod_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.digital_simple_correlator_0, 0),
                     (self.vocoder_alaw_decode_bs_0, 0))
        self.connect((self.digital_simple_framer_0, 0),
                     (self.digital_psk_mod_0, 0))
        self.connect((self.digital_simple_framer_0, 0), (self.fec_ber_bf_0, 0))
        self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.digital_simple_correlator_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_const_vxx_4, 0))
        self.connect((self.vocoder_alaw_decode_bs_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.vocoder_alaw_encode_sb_0, 0),
                     (self.digital_simple_framer_0, 0))
コード例 #40
0
ファイル: test_uci.py プロジェクト: teoyenmao/usrp_project
    def rx_node_callback(ok, payload):    # For Node
        global n_rcvd, n_right, mean_delta, next_tx_ts, stop_rx_ts, ps_end_ts, alloc_index, vf_index, \
            listen_only_to

        n_rcvd += 1

        (pktno,) = struct.unpack('!H', payload[0:2])
        # Filter out incorrect pkt
        if pktno >= wrong_pktno:
            logger.warning("Wrong pktno {}. Drop pkt!".format(pktno))
            return

        try:
            pkt_timestamp_str = payload[2:2+TIMESTAMP_LEN]
            pkt_timestamp = float(pkt_timestamp_str)
        except:
            logger.warning("Timestamp {} is not a float. Drop pkt!".format(pkt_timestamp_str))
            return

        now_timestamp = rx_tb.source.get_time_now().get_real_secs()
        # now_timestamp_str = '{:.3f}'.format(now_timestamp)
        delta = now_timestamp - pkt_timestamp   # +ve: BS earlier; -ve: Node earlier
        if not -5 < delta < 5:
            logger.warning("Delay out-of-range: {}, timestamp {}. Drop pkt!".format(delta, pkt_timestamp_str))
            return

        (pkt_type,) = struct.unpack('!H', payload[2+TIMESTAMP_LEN:2+TIMESTAMP_LEN+2])
        if pkt_type not in [PacketType.BEACON.index, PacketType.ACK_RESPOND.index,
                            PacketType.PS_BROADCAST.index, PacketType.VFS_BROADCAST.index]:
            logger.warning("Invalid pkt_type {}. Drop pkt!".format(pkt_type))
            return
        if listen_only_to and pkt_type not in listen_only_to:
            str_listen_only_to = [PacketType[x].key for x in listen_only_to]
            logger.warning("Interest only in pkt_type {}, not {}. Drop pkt!".format(str_listen_only_to, PacketType[pkt_type].key))
            return

        if pkt_type == PacketType.BEACON.index:
            delta_list.append(delta)
            # Keep delta_list in size limit
            if len(delta_list) > MAX_DELTA_AMT:
                delta_list.pop(0)
            mean_delta = numpy.mean(delta_list)
            # mean_delta_str = '{:07.3f}'.format(delta)
            # Adjust time if needed
            if not -0.05 <= mean_delta <= 0.05:
                rx_tb.source.set_time_now(uhd.time_spec(pkt_timestamp))
                now_timestamp = rx_tb.source.get_time_now().get_real_secs()
                logger.info("Adjust time... New time: {}".format(str(datetime.fromtimestamp(now_timestamp))))

            stop_rx_ts = now_timestamp + 0.5 - COMMAND_DELAY
            # Hack: for RX2400
            if pktno >= MAX_PKT_AMT - 10:
                stop_rx_ts -= 0.3

            logger.info("{} Node recv BEACON {}. BS time: {}, Avg delay: {}".format(
                str(datetime.fromtimestamp(now_timestamp)), pktno, str(datetime.fromtimestamp(pkt_timestamp)), mean_delta))
            # logger.debug("stop_rx_ts {}".format(str(datetime.fromtimestamp(stop_rx_ts))))
            return

        if pkt_type == PacketType.PS_BROADCAST.index:
            node_amount = ps_model.get_node_amount(payload)
            seed = ps_model.get_seed(payload)
            alloc_index = ps_model.compute_alloc_index(node_amount, NODE_ID, seed)
            try:
                begin_timestamp_str = ps_model.get_begin_time_str(payload)
                begin_timestamp = float(begin_timestamp_str)
            except:
                logger.warning("begin_timestamp {} is not a float. Drop pkt!".format(begin_timestamp_str))
                return

            stop_rx_ts = now_timestamp + 0.4
            # TODO: Duo to various delays, adjust a bit to before firing round up second
            next_tx_ts = begin_timestamp + (NODE_SLOT_TIME * alloc_index) - TRANSMIT_DELAY
            # Each node time slot at NODE_SLOT_TIME seconds
            ps_end_ts = begin_timestamp + (NODE_SLOT_TIME * node_amount)

            logger.info("{} Node recv PS_BROADCAST {}, BS time {}, Total {}, Seed {}, Index {}, Delay {}".format(
                str(datetime.fromtimestamp(now_timestamp)), pktno, str(datetime.fromtimestamp(pkt_timestamp)),
                node_amount, seed, alloc_index, delta))
            # logger.debug("begin {}, stop_rx_ts {}, next_tx_ts {}, ps_end_ts {}".format(
            #     str(datetime.fromtimestamp(begin_timestamp)), str(datetime.fromtimestamp(stop_rx_ts)),
            #     str(datetime.fromtimestamp(next_tx_ts)), str(datetime.fromtimestamp(ps_end_ts))))
            return

        if pkt_type == PacketType.VFS_BROADCAST.index:
            node_amount = vfs_model.get_node_amount(payload)
            seed = ps_model.get_seed(payload)
            try:
                begin_timestamp_str = vfs_model.get_begin_time_str(payload)
                begin_timestamp = float(begin_timestamp_str)
            except:
                logger.warning("begin_timestamp {} is not a float. Drop pkt!".format(begin_timestamp_str))
                return
            try:
                v_frame = vfs_model.get_v_frame(payload)
            except:
                logger.warning("Cannot extract v-frame. Drop pkt!")
                return
            vf_index = vfs_model.compute_vf_index(len(v_frame), NODE_ID, seed)
            alloc_index, in_rand_frame = vfs_model.compute_alloc_index(vf_index, NODE_ID, v_frame, node_amount)

            stop_rx_ts = now_timestamp + 0.4
            # TODO: Duo to various delays, adjust a bit to before firing round up second
            next_tx_ts = begin_timestamp + (NODE_SLOT_TIME * alloc_index) - TRANSMIT_DELAY

            logger.info("{} Node recv VFS_BROADCAST {}, BS time {}, Total {}, Seed {}, Delay {}, "
                        "\nv-frame index: {}, alloc-index: {}, fall to rand-frame: {},"
                        "\nv-frame: {}"
                        .format(str(datetime.fromtimestamp(now_timestamp)), pktno,
                                str(datetime.fromtimestamp(pkt_timestamp)),
                                node_amount, seed, delta, vf_index, alloc_index, in_rand_frame, v_frame))
            # logger.debug("begin {}, stop_rx_ts {}, next_tx_ts {}".format(
            #     str(datetime.fromtimestamp(begin_timestamp)), str(datetime.fromtimestamp(stop_rx_ts)),
            #     str(datetime.fromtimestamp(next_tx_ts))))
            return
コード例 #41
0
    def __init__(self,
                 adcs_freq=465.9875e6,
                 adcs_gain=25,
                 gs_name='GS1',
                 sarsat_freq=1544.5e6,
                 sarsat_gain=25,
                 sat_name='METOPB'):
        gr.top_block.__init__(self, "Adcs Pds Record Gui")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Adcs Pds Record Gui")
        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", "adcs_pds_record_gui")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.adcs_freq = adcs_freq
        self.adcs_gain = adcs_gain
        self.gs_name = gs_name
        self.sarsat_freq = sarsat_freq
        self.sarsat_gain = sarsat_gain
        self.sat_name = sat_name

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(),
                                           "%Y%m%d_%H%M%S.%f") + '_UTC'
        self.samp_rate = samp_rate = 1000000
        self.decim = decim = 4
        self.sarsat_fn = sarsat_fn = "{:s}_{:s}_SARSAT_{:s}_{:s}k.fc32".format(
            gs_name, sat_name, ts_str, str(int(samp_rate / decim) / 1000))
        self.adcs_fn = adcs_fn = "{:s}_{:s}_ADCS_{:s}_{:s}k.fc32".format(
            gs_name, sat_name, ts_str, str(int(samp_rate / decim) / 1000))
        self.sarsat_fp = sarsat_fp = "/mnt/usbhdd/{:s}".format(sarsat_fn)
        self.adcs_fp = adcs_fp = "/mnt/usbhdd/{:s}".format(adcs_fn)

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_clock_source('gpsdo', 0)
        self.uhd_usrp_source_0.set_time_source('gpsdo', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate / decim)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(adcs_freq, (samp_rate / decim) / 2), 0)
        self.uhd_usrp_source_0.set_gain(adcs_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim,  #bw
            "ADCS - UHF",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-120, -40)
        self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_0_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0_0.enable_grid(True)
        self.qtgui_freq_sink_x_0_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0_0.disable_legend()

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

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [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_layout.addWidget(self._qtgui_freq_sink_x_0_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "SARSAT",  #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, -40)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'rtl=SARSAT')
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(sarsat_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(2, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(sarsat_gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                     adcs_fp, False)
        self.blocks_file_sink_1_0.set_unbuffered(False)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   sarsat_fp, False)
        self.blocks_file_sink_1.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_file_sink_1_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_freq_sink_x_0_0, 0))
コード例 #42
0
    def __init__(self, frame_size=32, puncpat='11'):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Parameters
        ##################################################
        self.frame_size = frame_size
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.samples_per_symbol = samples_per_symbol = 64
        self.rate = rate = 2
        self.polys = polys = [79, 109]
        self.k = k = 7
        self.bitrate = bitrate = 9600
        self.samp_rate = samp_rate = samples_per_symbol*bitrate
        self.gain = gain = 50
        
        
        self.dec_cc = dec_cc = fec.cc_decoder.make(frame_size, k, rate, (polys), 0, -1, fec.CC_STREAMING, False)
            
        self.centre_freq = centre_freq = 401e6
        self.bandwidth = bandwidth = 200e3

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 100, 1, 50, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(centre_freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_bandwidth(bandwidth, 0)
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._show_text_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	2048, #size
        	bitrate, #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(-128, 128)
        
        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)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._fosphor_qt_sink_c_0_win)
        self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=dec_cc, threading= None, ann=None, puncpat=puncpat, integration_period=10000)
        self.digital_map_bb_0 = digital.map_bb(([-1, 1]))
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=samples_per_symbol,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.ccsds_asm_deframer_0 = ccsds.asm_deframer(0,1,False,16)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/gs-laptop1/GroundStation/GroundStation/GNURadio/Test Files/Simple GMSK Receive/out.bin", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-40, 1e-4, 0, True)
        self.ais_invert_0 = ais.invert()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ais_invert_0, 0), (self.digital_map_bb_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.digital_gmsk_demod_0, 0))    
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_char_to_float_0_0, 0), (self.fec_extended_decoder_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ccsds_asm_deframer_0, 0), (self.show_text_0, 0))    
        self.connect((self.digital_gmsk_demod_0, 0), (self.ais_invert_0, 0))    
        self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_0, 0))    
        self.connect((self.fec_extended_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
        self.connect((self.fec_extended_decoder_0, 0), (self.ccsds_asm_deframer_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_qt_sink_c_0, 0))    
コード例 #43
0
ファイル: satsdr_0002.py プロジェクト: pavelfpl/gr-gsSDR
    def __init__(self):
        gr.top_block.__init__(self, "gr-vzlu test")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 192000
        self.gain_set = gain_set = 40
        self.freq = freq = 437.242e6

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )
        self.uhd_usrp_source_0.set_subdev_spec('A:A', 0)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain_set, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.satellites_u482c_deframer_0 = satellites.components.deframers.u482c_deframer(
            syncword_threshold=3, options="")
        self.satellites_afsk_demodulator_0 = satellites.components.demodulators.afsk_demodulator(
            baudrate=4800,
            samp_rate=samp_rate,
            iq=True,
            af_carrier=3600,
            deviation=-1200,
            options="")
        self.gsSDR_http_transfer_sink_0 = gsSDR.http_transfer_sink(
            'localhost', '8080', '/gs/tm', 0, 2, '', '')
        self.gsSDR_gs_doppler_correction_0 = gsSDR.gs_doppler_correction(
            'localhost', '4534', 1, freq)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_debug_1 = blocks.message_debug()
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 0, 1, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.gsSDR_gs_doppler_correction_0, 'out_rx'),
                         (self.analog_sig_source_x_0, 'freq'))
        self.msg_connect((self.gsSDR_gs_doppler_correction_0, 'out_rx'),
                         (self.blocks_message_debug_1, 'print'))
        self.msg_connect((self.satellites_u482c_deframer_0, 'out'),
                         (self.gsSDR_http_transfer_sink_0, 'in'))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.satellites_afsk_demodulator_0, 0))
        self.connect((self.satellites_afsk_demodulator_0, 0),
                     (self.satellites_u482c_deframer_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
コード例 #44
0
    def __init__(self):
        gr.top_block.__init__(self, "Calibration Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Calibration Example")
        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", "calibration_example_gui_2x")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.speed_of_light = speed_of_light = 299792458
        self.antenna_spacing = antenna_spacing = 0.1
        self.samp_rate = samp_rate = 100000000 / 64
        self.gain_rx = gain_rx = 0
        self.center_freq = center_freq = speed_of_light / (2 * antenna_spacing)
        self.cal_freq = cal_freq = 1024

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0_0_0 = uhd.usrp_source(
            ",".join(("addr0=192.168.70.2,addr1=192.168.20.2,addr2=192.168.30.2,addr3=192.168.50.2", "")),
            uhd.stream_args(cpu_format="fc32", channels=range(4)),
        )
        self.uhd_usrp_source_0_0_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0_0_0.set_time_source("external", 0)
        self.uhd_usrp_source_0_0_0.set_clock_source("external", 1)
        self.uhd_usrp_source_0_0_0.set_time_source("external", 1)
        self.uhd_usrp_source_0_0_0.set_clock_source("external", 2)
        self.uhd_usrp_source_0_0_0.set_time_source("external", 2)
        self.uhd_usrp_source_0_0_0.set_clock_source("external", 3)
        self.uhd_usrp_source_0_0_0.set_time_source("external", 3)
        self.uhd_usrp_source_0_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0_0.set_samp_rate(samp_rate)

        # Tell boards to run these commands at this specific time in the future
        cmd_time = self.uhd_usrp_source_0_0_0.get_time_now() + uhd.time_spec_t(1.0)

        s1 = 0
        s2 = 5
        s3 = 700
        s4 = 640

        cmd_time1 = cmd_time + uhd.time_spec_t(0)
        cmd_time2 = cmd_time + uhd.time_spec_t(s2 / samp_rate)
        cmd_time3 = cmd_time + uhd.time_spec_t(s3 / samp_rate)
        cmd_time4 = cmd_time + uhd.time_spec_t(s4 / samp_rate)

        self.uhd_usrp_source_0_0_0.set_command_time(cmd_time1, 0)
        self.uhd_usrp_source_0_0_0.set_command_time(cmd_time2, 1)
        self.uhd_usrp_source_0_0_0.set_command_time(cmd_time3, 2)
        self.uhd_usrp_source_0_0_0.set_command_time(cmd_time4, 3)

        self.uhd_usrp_source_0_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0_0_0.set_gain(gain_rx, 0)
        self.uhd_usrp_source_0_0_0.set_center_freq(center_freq, 1)
        self.uhd_usrp_source_0_0_0.set_gain(gain_rx, 1)
        self.uhd_usrp_source_0_0_0.set_center_freq(center_freq, 2)
        self.uhd_usrp_source_0_0_0.set_gain(gain_rx, 2)
        self.uhd_usrp_source_0_0_0.set_center_freq(center_freq, 3)
        self.uhd_usrp_source_0_0_0.set_gain(gain_rx, 3)

        self.uhd_usrp_source_0_0_0.clear_command_time()
        time.sleep(1.5)

        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("addr=192.168.40.2", "")), uhd.stream_args(cpu_format="fc32", channels=range(1))
        )
        self.uhd_usrp_sink_0_0.set_clock_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_time_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0_0.set_gain(10, 0)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1526 * 2, samp_rate, "", 4  # size  # samp_rate  # name  # 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_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(True)

        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(4):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.blocks_complex_to_real_1_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_1 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0), (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_complex_to_real_1_0, 0), (self.qtgui_time_sink_x_0, 3))
        self.connect((self.uhd_usrp_source_0_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.uhd_usrp_source_0_0_0, 2), (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0_0, 1), (self.blocks_complex_to_real_1, 0))
        self.connect((self.uhd_usrp_source_0_0_0, 3), (self.blocks_complex_to_real_1_0, 0))
コード例 #45
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM_TX_RX_1")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OFDM_TX_RX_1")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "OFDM_TX_RX_1")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.occupied_carriers = occupied_carriers = (
            list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) +
            list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), )
        self.length_tag_key_rx = length_tag_key_rx = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.samp_rate = samp_rate = 1000000
        self.rolloff = rolloff = 0
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 1)
        self.packet_len = packet_len = 30
        self.length_tag_key = length_tag_key = "packet_len"
        self.header_len = header_len = 10
        self.header_formatter = header_formatter = digital.packet_header_ofdm(
            occupied_carriers,
            n_syms=1,
            len_tag_key=packet_length_tag_key,
            frame_len_tag_key=length_tag_key_rx,
            bits_per_header_sym=header_mod.bits_per_symbol(),
            bits_per_payload_sym=payload_mod.bits_per_symbol(),
            scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols)

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=[],
            ),
            '',
        )
        self.uhd_usrp_sink_0.set_center_freq(3.555e9, 0)
        self.uhd_usrp_sink_0.set_gain(31, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_bandwidth(0.5e6, 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec())
        self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (), True, 1)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            digital.header_format_ofdm(
                occupied_carriers,
                1,
                length_tag_key,
            ), length_tag_key)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + 16, rolloff, length_tag_key)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols,
            (sync_word1, sync_word2), length_tag_key, True)
        self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            payload_mod.points(), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            header_mod.points(), 1)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, length_tag_key, 0)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, length_tag_key)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            8, 1, length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/local/repository/gnuradio/file_to_transmit.txt', False, 0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_crc32_bb_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
コード例 #46
0
    def __init__(self, addr, no_usrp, initialFreq, otw, source, no_self_loop,
                 debug_MAC, wireshark):
        gr.top_block.__init__(
            self, "IEEE 802.15.4m Slave Node Transceiver using OQPSK")
        Qt.QWidget.__init__(self)
        self.setWindowTitle(
            "IEEE 802.15.4m Slave Node Transceiver using OQPSK")
        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", "transceiver_OQPSK_Slave")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.addr = addr
        self.no_usrp = no_usrp
        self.freq = initialFreq
        self.otw = otw
        self.no_self_loop = no_self_loop
        self.debug_MAC = debug_MAC
        self.source = source
        self.wireshark = wireshark
        self.tx_gain = tx_gain = 0.25
        self.rx_gain = rx_gain = 0.25
        ##################################################
        # Blocks
        ##################################################
        if self.no_usrp:
            self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                     4 * 1e6, True)
            ## Using files instead of USRPs
            self.blocks_file_source_slave = blocks.file_source(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/masterFileSink"), True)
            self.blocks_file_sink_slave = blocks.file_sink(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/slaveFileSink"), False)
            self.blocks_file_sink_slave.set_unbuffered(False)
        else:
            ## usrp_source
            self.uhd_usrp_source_0 = uhd.usrp_source(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )
            ## usrp_sink
            self.uhd_usrp_sink_0 = uhd.usrp_sink(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )

            # TODO Explain the usage
            self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                                uhd.ALL_MBOARDS)
            self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
            self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
            self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)

        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            4e6,  #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 True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)

        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        # 802.15.4m MAC layer #
        #self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.ieee802_15_4_mac_0 = mac_15_4m(self.debug_MAC, self.no_self_loop)
        # Ethernet Encapsulation #TODO explain its usage, Specific to 802.11 ?
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)

        self._freq_options = [
            TVWS_channelmap.get_TVWS_freq(i) for i in range(2, 69)
        ]
        self._freq_labels = [str(i) for i in range(2, 69)]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))

        self.top_layout.addWidget(self._freq_tool_bar)

        ##################################################
        # Asynch Message Connections
        ##################################################
        if self.source == "tuntap":  # Tuntap Block to quantify the achievable throughput
            print "TUNTAP"
            self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap1", 440)
            self.msg_connect(self.ieee802_11_ether_encap_0, "to tap",
                             self.blocks_tuntap_pdu_0, "pdus")
            self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                             self.ieee802_11_ether_encap_0, "from tap")

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                             self.ieee802_11_ether_encap_0, "from wifi")
            self.msg_connect(self.ieee802_11_ether_encap_0, "to wifi",
                             self.ieee802_15_4_rime_stack_0, "bcin")

        elif self.source == "socket":  #using PDU Sockets instead #TODO Test ME !
            self.blocks_socket_pdu_0_Tx = blocks.socket_pdu(
                "UDP_SERVER", "localhost", "52004", 10000)
            self.blocks_socket_pdu_0_Rx = blocks.socket_pdu(
                "UDP_CLIENT", "localhost", "3333", 10000)

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                             self.blocks_socket_pdu_0_Rx, "pdus")
            self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus",
                             self.ieee802_15_4_rime_stack_0, "bcin")

        elif self.source == "strobe":
            self.blocks_message_strobe_0 = blocks.message_strobe(
                pmt.intern("Hello World!\n"), 1000)
            self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                             (self.ieee802_15_4_rime_stack_0, 'bcin'))

        if self.wireshark:
            self.foo_wireshark_connector_0 = foo.wireshark_connector(127, True)

            self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                       "/tmp/ofdm.pcap", True)
            self.blocks_file_sink_0.set_unbuffered(True)

            self.connect((self.foo_wireshark_connector_0, 0),
                         (self.blocks_file_sink_0, 0))

            self.msg_connect(self.ieee802_15_4_mac_0, "PHY",
                             self.foo_wireshark_connector_0, "in")
            self.msg_connect(self.ieee802_15_4_oqpsk_phy_0, "mac_out",
                             self.foo_wireshark_connector_0, "in")

        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        if self.no_usrp:
            self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                         ((self.blocks_file_sink_slave, 0)))
            self.connect((self.blocks_file_source_slave, 0),
                         (self.ieee802_15_4_oqpsk_phy_0, 0))
        else:
            self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                         ((self.uhd_usrp_sink_0, 0)))
            self.connect((self.uhd_usrp_source_0, 0),
                         (self.ieee802_15_4_oqpsk_phy_0, 0))
コード例 #47
0
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Tx No Gui")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tx No Gui")
        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", "tx_no_gui")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952, 200000
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22
        self.H = H = fec.ldpc_H_matrix(
            '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist',
            24)
        self.vector = vector = [int(random.random() * 4) for i in range(49600)]
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 43

        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, eb, 11 * sps * nfilts)

        self.samp_rate = samp_rate = samp_rate_array_MCR[17]

        self.pld_enc = pld_enc = map(
            (lambda a: fec.ldpc_par_mtrx_encoder_make_H(H)), range(0, 4))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 43, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'Gain_TX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 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.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAE1", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self.scrambler_cpp_additive_scrambler_0 = scrambler_cpp.additive_scrambler(
            0x8A, 0x7F, 7, 440 - 32)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

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

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

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1, 3, 1,
                                       1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(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 True:
            self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 3, 1,
                                       1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "TX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 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.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector))
        self.fec_extended_encoder_0 = fec.extended_encoder(
            encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(
            pld_const.arity())
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_const.points()), 1)
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True,
                                                                   1, [])
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b([0], True, 1,
                                                                 [])
        self.blocks_stream_mux_0_1_0_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (96, 1104))
        self.blocks_stream_mux_0_0_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (1100, 4))
        self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1,
                                                       (440, 2))
        self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb(
            8, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb(
            1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_file_source_0_0_1_0_1 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/andre/Desktop/Files_To_Transmit/book.txt', False)
        self.blocks_file_source_0_0_1_0_1.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_gr_complex * 1,
            '/home/andre/Desktop/MET_QUINTA/0/ALICE.txt', False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 500000)
        self.acode_1104_0 = blocks.vector_source_b([
            0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1,
            0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0,
            0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0,
            0x0, 0x1, 0x0, 0x1, 0x0
        ], True, 1, [])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.acode_1104_0, 0),
                     (self.blocks_stream_mux_0_1_0_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_delay_0, 0), (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.blocks_file_source_0_0_1_0_1, 0),
                     (self.blocks_repack_bits_bb_1_0_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.scrambler_cpp_additive_scrambler_0, 0))
        self.connect((self.blocks_stream_mux_0_0, 0),
                     (self.fec_extended_encoder_0, 0))
        self.connect((self.blocks_stream_mux_0_0_0, 0),
                     (self.blocks_stream_mux_0_1_0_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_stream_mux_0_0, 1))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_stream_mux_0_0_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.fec_extended_encoder_0, 0),
                     (self.blocks_stream_mux_0_0_0, 0))
        self.connect((self.insert_vec_cpp_new_vec_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.scrambler_cpp_additive_scrambler_0, 0),
                     (self.blocks_stream_mux_0_0, 0))
コード例 #48
0
ファイル: gr_sweepsense.py プロジェクト: gmg2719/SweepSense
    def __init__(self, options, filename):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Blocks
        ##################################################
        self.usrp_source = uhd.usrp_source(
            ",".join((options.dev_args, "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        if options.mode != 2:
            self.uhd_usrp_sink_0 = uhd.usrp_sink(
                ",".join((options.dev_args, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )

        # Initialization code for controlling the DAC output
        self.chan = 0
        self.unit = uhd.dboard_iface.UNIT_TX
        self.dac = uhd.dboard_iface.AUX_DAC_A
        self.iface = self.usrp_source.get_dboard_iface(self.chan)
        #self.iface.write_aux_dac_config(32)
        self.iface.write_aux_dac(self.unit, self.dac, 0.2)

        # Configure frequency band registers (depending on daughter board)
        # Channel 1 on MIMO cable is the sweeper USRP
        usrp_info = self.usrp_source.get_usrp_info(0)
        db_name = usrp_info["rx_subdev_name"]
        user_reg_1 = 0
        user_reg_2 = 0
        print("NAME: " + db_name)
        if (db_name.find("SBX") != -1):
            # The following two registers can be configured for frequency band
            # 2.4 GHz comes in 16 and 24
            # for all 37 bands, put 4294967295 in reg 1 and 31 in reg 2
            stderr.write("Detected SBX DB...\n")
            user_reg_1 = 48  # frequncy bit array for first 32 bands  #32-band6#64-band7
            user_reg_2 = 0  # frequency bit array for next 5 bands
        elif (db_name.find("CBX") != -1):
            # 2.4 GHz
            stderr.write("Detected CBX DB...\n")
            user_reg_1 = options.band1  # frequncy bit array for first 32 bands
            user_reg_2 = options.band2  # frequency bit array for next 32 bands
        else:
            stderr.write("Error: Unknown daughterboard: %s\n" % db_name)
            exit(1)

        # Set chirp enable:
        self.usrp_source.set_user_register(3, 1, 0)

        # Set bands of interest
        self.usrp_source.set_user_register(1, user_reg_1, 0)
        self.usrp_source.set_user_register(2, user_reg_2, 0)
        #Address 5 -Clk divider
        self.usrp_source.set_user_register(5, 4, 0)

        #self.usrp_source.set_user_register(6,1,0) # RF divider to give 400-4.4GHz range. Valid values are 1,2,4,8 and 16.
        # The following are the new registers that need to be set
        # for the updated hardware code.
        # register 4 = jump value - 12 bit number
        self.usrp_source.set_user_register(4, options.step, 0)
        # register 7 = start_ramp - 12 bit number
        self.usrp_source.set_user_register(7, 621, 0)
        # register 8 = end_ramp - 12 bit number
        self.usrp_source.set_user_register(8, 3103, 0)
        # RF Divider parameters
        self.usrp_source.set_user_register(6, options.rf_div, 0)

        # Set source parameters
        self.usrp_source.set_antenna("RX2")
        self.usrp_source.set_samp_rate(options.samp)
        self.usrp_source.set_bandwidth(options.samp, 0)
        self.usrp_source.set_gain(options.rgain, 0)

        if options.mode != 2:
            # Set sink parameters
            self.uhd_usrp_sink_0.set_samp_rate(10e6)
            self.uhd_usrp_sink_0.set_center_freq(options.txfreq, 0)
            self.uhd_usrp_sink_0.set_gain(options.tgain, 0)
            self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
            self.uhd_usrp_sink_0.set_bandwidth(25e6, 0)
            # signal gen blocker
            self.blocks_head_0 = blocks.head(
                gr.sizeof_gr_complex * 1,
                options.inN * options.maxsamp + options.skip)
            # Signal Source
            self.analog_sig_source_x_0 = analog.sig_source_c(
                options.samp, analog.GR_CONST_WAVE, 0, 0, 1)

        self.usrp_source.set_clock_source('internal', 0)
        self.usrp_source.set_time_now(uhd.time_spec(time.time()),
                                      uhd.ALL_MBOARDS)

        # Skip Heads
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1,
                                                 options.skip)

        # Block Heads
        self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex * 1,
                                         options.maxsamp)

        # File meta sink
        pmt_a = pmt.make_dict()
        self.blocks_file_sink_0 = blocks.file_meta_sink(
            gr.sizeof_gr_complex * 1, filename[0], options.samp, 1,
            blocks.GR_FILE_FLOAT, True, options.sweep_time, pmt_a, True)
        self.blocks_file_sink_0.set_unbuffered(False)

        # Keep M in N
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(
            gr.sizeof_gr_complex, options.sweep_time * options.num_bands,
            options.sweep_time * options.num_bands * options.inN, 0)

        ##################################################
        # Connections
        ##################################################

        # Sweeper RX Flow
        self.connect((self.usrp_source, 0), (self.blocks_skiphead_0))
        self.connect((self.blocks_skiphead_0), (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_keep_m_in_n_0), (self.blocks_head_1, 0))

        #self.connect((self.blocks_skiphead_0),(self.blocks_head_1, 0))
        self.connect((self.blocks_head_1, 0), (self.blocks_file_sink_0, 0))

        if options.mode != 2:
            # Tone TX Flow
            self.connect((self.analog_sig_source_x_0, 0),
                         (self.blocks_head_0, 0))
            self.connect((self.blocks_head_0, 0), (self.uhd_usrp_sink_0, 0))
コード例 #49
0
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Tx No Gui")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tx No Gui")
        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", "tx_no_gui")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22

        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, eb, 11 * sps * nfilts)

        self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952
        ]
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.vector = vector = [int(random.random() * 4) for i in range(49600)]
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 50
        self.samp_rate = samp_rate = samp_rate_array_MCR[3]

        self.pld_enc = pld_enc = map((lambda a: fec.cc_encoder_make(
            440, k, rate, (polys), 0, fec.CC_TERMINATED, False)), range(0, 8))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_0_range = Range(0, 90, 1, 50, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'Gain_TX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0,
                                       2, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAE1", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self.scrambler_cpp_additive_scrambler_0 = scrambler_cpp.additive_scrambler(
            0x8A, 0x7F, 7, 440 - 32)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay)

        self.insert_vec_cpp_new_vec_0 = insert_vec_cpp.new_vec((vector))
        self.fec_extended_encoder_0 = fec.extended_encoder(
            encoder_obj_list=pld_enc, threading='capillary', puncpat=puncpat)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(
            pld_const.arity())
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (pld_const.points()), 1)
        self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b([0], True,
                                                                   1, [])
        self.blocks_stream_mux_0_1_0 = blocks.stream_mux(
            gr.sizeof_char * 1, (96, 896))
        self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_char * 1,
                                                       (892, 4))
        self.blocks_repack_bits_bb_1_0_0_1 = blocks.repack_bits_bb(
            8, 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_1_0_0_0 = blocks.repack_bits_bb(
            1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_file_source_0_0_1_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/andre/Desktop/Files_To_Transmit/trasmit_10_mb.txt', False)
        self.blocks_file_source_0_0_1_0.set_begin_tag(pmt.PMT_NIL)
        self.acode_1104 = blocks.vector_source_b([
            0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1,
            0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0,
            0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1,
            0x1, 0x0, 0x0, 0x0, 0x0
        ], True, 1, [])

        ##################################################
        # Connections
        ##################################################
        self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0))
        self.connect((self.blocks_file_source_0_0_1_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_0, 0),
                     (self.insert_vec_cpp_new_vec_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0_0_1, 0),
                     (self.scrambler_cpp_additive_scrambler_0, 0))
        self.connect((self.blocks_stream_mux_0_0, 0),
                     (self.blocks_stream_mux_0_1_0, 1))
        self.connect((self.blocks_stream_mux_0_1_0, 0),
                     (self.blocks_repack_bits_bb_1_0_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_0_0, 0),
                     (self.blocks_stream_mux_0_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.fec_extended_encoder_0, 0),
                     (self.blocks_stream_mux_0_0, 0))
        self.connect((self.insert_vec_cpp_new_vec_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.scrambler_cpp_additive_scrambler_0, 0),
                     (self.fec_extended_encoder_0, 0))
コード例 #50
0
    def __init__(self):
        gr.top_block.__init__(self, "Uhd Bfm")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Uhd Bfm")
        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_bfm")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2.5e6
        self.volume = volume = .01
        self.rx_gain = rx_gain = 30
        self.rx_freq = rx_freq = 91e6
        self.lpf_cutoff = lpf_cutoff = 96e3
        self.interp = interp = 192
        self.decim = decim = samp_rate / 1e3
        self.decay_rate = decay_rate = 100e-6

        ##################################################
        # Blocks
        ##################################################
        self._volume_range = Range(0, 1, .001, .01, 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._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain" + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(
                str(self._rx_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_gain_tool_bar, 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_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel("rx_freq" + ": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq(
            eng_notation.str_to_num(
                str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 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._lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._lpf_cutoff_tool_bar.addWidget(Qt.QLabel("lpf_cutoff" + ": "))
        self._lpf_cutoff_line_edit = Qt.QLineEdit(str(self.lpf_cutoff))
        self._lpf_cutoff_tool_bar.addWidget(self._lpf_cutoff_line_edit)
        self._lpf_cutoff_line_edit.returnPressed.connect(
            lambda: self.set_lpf_cutoff(
                eng_notation.str_to_num(
                    str(self._lpf_cutoff_line_edit.text().toAscii()))))
        self.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.uhd_usrp_source_1 = uhd.usrp_source(
            ",".join(("serial=318692D", "")),
            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_subdev_spec('A:A', 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(rx_freq, 0)
        self.uhd_usrp_source_1.set_gain(rx_gain, 0)
        self.uhd_usrp_source_1.set_antenna('RX2', 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_fff(
            interpolation=1,
            decimation=4,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=500,
            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_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate / decim * interp / 4,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.010)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 100)

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

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

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 6, 6,
                                       3, 2)
        for r in range(6, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        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,  #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_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff, 100,
                            firdes.WIN_HAMMING, 6.76))
        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) * 500)
        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._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.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((100, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff(
            (volume, ))
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.audio_sink_0 = audio.sink(48000, '', True)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            samp_rate / (2 * math.pi * 96e3 / 8.0))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_complex_to_mag_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_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_0_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_multiply_const_vxx_0, 0))
        self.connect((self.uhd_usrp_source_1, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.uhd_usrp_source_1, 0),
                     (self.rational_resampler_xxx_0_0, 0))
コード例 #51
0
ファイル: syncB.py プロジェクト: kdescobar/Kevin
    def __init__(self):
        gr.top_block.__init__(self, "Timing Syncronization")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Timing Syncronization")
        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", "sync")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 3000000
        self.min_freq = min_freq = 0e3*(2*3.14)/samp_rate
        self.max_freq = max_freq = 20e3*(2*3.14)/samp_rate
        self.loop_bw = loop_bw = 1e3*(2*3.14)/samp_rate
        self.fc = fc = 2.45e9

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_clock_source('internal', 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(fc, 0)
        self.uhd_usrp_source_0.set_gain(30, 0)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(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 True:
          self.qtgui_freq_sink_x_0.disable_legend()

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

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

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
コード例 #52
0
    def __init__(self):
        gr.top_block.__init__(self, "Bob")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Bob")
        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", "bob")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952, 200000
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = rpower
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = jpower
        self.samp_rate = samp_rate = samp_rate_array_MCR[17]

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts)

        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.gui_lambda = gui_lambda = 1
        self.gui_delta = gui_delta = 1
        self.frequencia_usrp = frequencia_usrp = 24e8
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, rpower, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_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._variable_qtgui_range_0_0_range = Range(0, 90, 1, jpower, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'Gain_Jamming',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 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._gui_lambda_range = Range(0.01, 1, 0.01, 1, 100)
        self._gui_lambda_win = RangeWidget(self._gui_lambda_range,
                                           self.set_gui_lambda, 'Lambda',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._gui_lambda_win, 0, 4, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gui_delta_range = Range(0.01, 1, 0.01, 1, 300)
        self._gui_delta_win = RangeWidget(self._gui_delta_range,
                                          self.set_gui_delta, 'Delta',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._gui_delta_win, 0, 3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("serial=F5EAC0", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAC0", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX JAMMING USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #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, 256)

        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_FREE,
                                                      qtgui.TRIG_SLOPE_POS,
                                                      0.0, 0, 0,
                                                      'packet_length_tag_key')
        self.qtgui_time_sink_x_0_1_0.enable_autoscale(True)
        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 = ['', '', '', '', '', '', '', '', '', '']
        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_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, 2, 3,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

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

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

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 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.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "RX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_1.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(
            4, ([1, 0, 0, 0]))
        self.interp_fir_filter_xxx_1.declare_sample_delay(0)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(
            pld_const.arity())
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 100.0, pld_const.arity(), False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            pld_const)
        self.digital_cma_equalizer_cc_0_0 = digital.cma_equalizer_cc(
            15, 1, 0.01, 2)
        self.custom_corr = correlate_and_delay.corr_and_delay(
            200 * sps, 0, 0.9995, sps)
        self.cac_cpp_cac_bb_0 = cac_cpp.cac_bb(
            digital.packet_utils.default_access_code, 1)
        self.blocks_repack_bits_bb_0_0_0_1_0_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, ))
        self.blocks_keep_m_in_n_0_0_2_0_0 = blocks.keep_m_in_n(
            gr.sizeof_char, 1100, 1104, 0)
        self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink(
            gr.sizeof_char * 1,
            '/home/it/ELI/' + num + '/BOB_55_8000_BRUTO.txt', False)
        self.blocks_file_sink_0_0_0_0_2.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1, '/home/it/ELI/' + num + '/BOB_EVM.txt',
            False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_char_to_float_1_0_1_0 = blocks.char_to_float(1, 1)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, -5)
        self.adapt_qrd_rls_filter_xx_0 = adapt.qrd_rls_filter_cc(
            12, gui_delta, gui_lambda, 1, 1, True, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.adapt_qrd_rls_filter_xx_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.adapt_qrd_rls_filter_xx_0, 1),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0),
                     (self.interp_fir_filter_xxx_1, 0))
        self.connect((self.blocks_char_to_float_1_0_1_0, 0),
                     (self.qtgui_time_sink_x_0_1_0, 0))
        self.connect((self.blocks_keep_m_in_n_0_0_2_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0_1_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.custom_corr, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_time_sink_x_1_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.cac_cpp_cac_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0_0, 0),
                     (self.blocks_char_to_float_1_0_1_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0_0, 0),
                     (self.blocks_file_sink_0_0_0_0_2, 0))
        self.connect((self.cac_cpp_cac_bb_0, 0),
                     (self.blocks_keep_m_in_n_0_0_2_0_0, 0))
        self.connect((self.custom_corr, 0),
                     (self.adapt_qrd_rls_filter_xx_0, 1))
        self.connect((self.custom_corr, 1),
                     (self.adapt_qrd_rls_filter_xx_0, 0))
        self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0))
        self.connect((self.digital_cma_equalizer_cc_0_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0_0, 0))
        self.connect((self.interp_fir_filter_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
コード例 #53
0
ファイル: stream_usrp.py プロジェクト: denniszollo/peregrine
    def __init__(self, filenames, dev_addrs,
                 onebit, iq, noise, mix, gain, fs, fc, unint, sync_pps):
        gr.top_block.__init__(self)

        if mix:
            raise NotImplementedError("TODO: Hilbert remix mode not implemented.")

        uhd_sinks = [
            uhd.usrp_sink(",".join(
                [addr, "send_frame_size=32768,num_send_frames=128"]),
                          uhd.stream_args(
                              cpu_format="fc32",
                              otwformat="sc8",
                              channels=[0]))
            for addr in dev_addrs]

        for sink in uhd_sinks:
            sink.set_clock_rate(fs*2, uhd.ALL_MBOARDS)
            sink.set_samp_rate(fs)
            sink.set_center_freq(fc, 0)
            sink.set_gain(gain, 0)
            # TODO Use offset tuning?
            if sync_pps:
                sink.set_clock_source("external") # 10 MHz
                sink.set_time_source("external") # PPS

        if unint:
            if noise or onebit or not iq:
                raise NotImplementedError("TODO: RX channel-interleaved mode only "
                                          "supported for noiseless 8-bit complex.")
            
            BLOCK_N=16*1024*1024
            demux = blocks.vector_to_streams(2, len(uhd_sinks))
            self.connect(blocks.file_source(2*len(uhd_sinks)*BLOCK_N, filenames[0], False),
                         blocks.vector_to_stream(2*len(uhd_sinks), BLOCK_N),
                         demux)
            for ix, sink in enumerate(uhd_sinks):
                self.connect((demux, ix),
                             blocks.vector_to_stream(1, 2),
                             blocks.interleaved_char_to_complex(), # [-128.0, +127.0]
                             blocks.multiply_const_cc(1.0/1024), # [-0.125, 0.125)
#                             blocks.vector_to_stream(8, 16*1024),
                             sink)

        else:
            file_srcs = [blocks.file_source(gr.sizeof_char*1, f, False)
                         for f in filenames]

            for src, sink in zip(file_srcs, uhd_sinks):

                if iq:
                    node = blocks.multiply_const_cc(1.0/1024)
                    if onebit:
                        self.connect(src,
                                     blocks.unpack_k_bits_bb(8), 
                                     blocks.char_to_short(), # [0, 1] -> [0, 256]
                                     blocks.add_const_ss(-128), # [-128, +128],
                                     blocks.interleaved_short_to_complex(), # [ -128.0, +128.0]
                                     node) # [-0.125, +0.125]
                    else:
                        self.connect(src, # [-128..127]
                                     blocks.interleaved_char_to_complex(), # [-128.0, +127.0]
                                     node) # [-0.125, +0.125)
                    
                else:
                    node = blocks.float_to_complex(1)
                    if onebit:
                        self.connect(src,
                                     blocks.unpack_k_bits_bb(8), # [0, 1] -> [-0.125, +0.125]
                                     blocks.char_to_float(vlen=1, scale=4),
                                     blocks.add_const_vff((-0.125, )),
                                     node)
                    else:
                        self.connect(src, # [-128..127] -> [-0.125, +0.125)
                                     blocks.char_to_float(vlen=1, scale=1024),
                                     node)
                        
                if noise:
                    combiner = blocks.add_vcc(1)
                    self.connect(node,
                                 combiner,
                                 sink)
                    self.connect(analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise, -222, 8192),
                                 (combiner, 1))
                else:
                    self.connect(node,
                                 sink)

        print "Setting clocks..."
        if sync_pps:
            time.sleep(1.1) # Ensure there's been an edge.  TODO: necessary?
            last_pps_time = uhd_sinks[0].get_time_last_pps()
            while last_pps_time == uhd_sinks[0].get_time_last_pps():
                time.sleep(0.1)
            print "Got edge"
            [sink.set_time_next_pps(uhd.time_spec(round(time.time())+1)) for sink in uhd_sinks]
            time.sleep(1.0) # Wait for edge to set the clocks
        else:
            # No external PPS/10 MHz.  Just set each clock and accept some skew.
            t = time.time()
            [sink.set_time_now(uhd.time_spec(time.time())) for sink in uhd_sinks]
            if len(uhd_sinks) > 1:
                print "Uncabled; loosely synced only. Initial skew ~ %.1f ms" % (
                    (time.time()-t) * 1000)

        t_start = uhd.time_spec(time.time() + 1.5)
        [sink.set_start_time(t_start) for sink in uhd_sinks]
        print "ready"
コード例 #54
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Transceiver Tdma Tuntap 2")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 750e-3
        self.samp_rate = samp_rate = 5e6
        self.rx_gain = rx_gain = 500e-3
        self.pdu_length = pdu_length = 500
        self.mac_dst = mac_dst = [0x12, 0x34, 0x56, 0x78, 0x90, 0xaa]
        self.mac_addr = mac_addr = [0x12, 0x34, 0x56, 0x78, 0x90, 0xac]
        self.lo_offset = lo_offset = 0
        self.interval = interval = 1e3
        self.freq = freq = 2.52e9
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0_0.set_normalized_gain(tx_gain, 0)
        self.macprotocols_naive_tdma_0 = macprotocols.naive_tdma(
            False, (mac_addr), 9, 1000, False)
        self.macprotocols_frame_buffer_0 = macprotocols.frame_buffer(
            256, True, 0, True)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, False)
        self.ieee802_11_mac_0_0 = ieee802_11.mac(
            (mac_addr), (mac_dst), ([0xff, 0xff, 0xff, 0xff, 0xff, 255]))
        (self.ieee802_11_mac_0_0).set_min_output_buffer(256)
        (self.ieee802_11_mac_0_0).set_max_output_buffer(4096)
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/wifi_rx_all.pcap",
                                                   False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'),
                         (self.ieee802_11_ether_encap_0, 'from tap'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'),
                         (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'),
                         (self.ieee802_11_mac_0_0, 'app in'))
        self.msg_connect((self.ieee802_11_mac_0_0, 'phy out'),
                         (self.macprotocols_frame_buffer_0, 'app in'))
        self.msg_connect((self.macprotocols_frame_buffer_0, 'frame out 0'),
                         (self.macprotocols_naive_tdma_0, 'frame from buffer'))
        self.msg_connect((self.macprotocols_naive_tdma_0, 'frame to app'),
                         (self.ieee802_11_ether_encap_0, 'from wifi'))
        self.msg_connect((self.macprotocols_naive_tdma_0, 'frame request'),
                         (self.macprotocols_frame_buffer_0, 'req in 0'))
        self.msg_connect((self.macprotocols_naive_tdma_0, 'frame to phy'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.macprotocols_naive_tdma_0, 'frame from phy'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
コード例 #55
0
ファイル: rx.py プロジェクト: andrehoracio97/investigacao
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Rx")
        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", "rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952, 200000
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22
        self.H_dec = H_dec = fec.ldpc_H_matrix(
            '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist',
            24)
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 30
        self.variable_qtgui_range_0_0 = variable_qtgui_range_0_0 = 52
        self.variable_qtgui_check_box_0 = variable_qtgui_check_box_0 = True
        self.samp_rate = samp_rate = samp_rate_array_MCR[12]

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * 2, 1.0, eb, 11 * sps * nfilts)

        self.pld_dec = pld_dec = map((lambda a: fec.ldpc_bit_flip_decoder.make(
            H_dec.get_base_sptr(), 100)), range(0, 8))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 484e6
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 30, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 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._variable_qtgui_range_0_0_range = Range(0, 90, 1, 52, 200)
        self._variable_qtgui_range_0_0_win = RangeWidget(
            self._variable_qtgui_range_0_0_range,
            self.set_variable_qtgui_range_0_0, 'Gain_Jamming',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_0_win, 0,
                                       3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        _variable_qtgui_check_box_0_check_box = Qt.QCheckBox('ENABLE JAM')
        self._variable_qtgui_check_box_0_choices = {True: True, False: False}
        self._variable_qtgui_check_box_0_choices_inv = dict(
            (v, k)
            for k, v in self._variable_qtgui_check_box_0_choices.iteritems())
        self._variable_qtgui_check_box_0_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _variable_qtgui_check_box_0_check_box, "setChecked",
            Qt.Q_ARG("bool", self._variable_qtgui_check_box_0_choices_inv[i]))
        self._variable_qtgui_check_box_0_callback(
            self.variable_qtgui_check_box_0)
        _variable_qtgui_check_box_0_check_box.stateChanged.connect(
            lambda i: self.set_variable_qtgui_check_box_0(
                self._variable_qtgui_check_box_0_choices[bool(i)]))
        self.top_grid_layout.addWidget(_variable_qtgui_check_box_0_check_box,
                                       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.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("serial=F5EAC0", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("serial=F5EAC0", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_subdev_spec('A:B', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_sink_0.set_gain(variable_qtgui_range_0_0, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.scrambler_cpp_additive_descrambler_0 = scrambler_cpp.additive_descrambler(
            0x8A, 0x7F, 7, 440 - 32)
        self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "TX JAMMING USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_win, 1, 1,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 1, 3,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_0_1.disable_legend()

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

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

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

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

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

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 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.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "RX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_1.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       2, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.interp_fir_filter_xxx_1 = filter.interp_fir_filter_ccc(
            4, ([1, 0, 0, 0]))
        self.interp_fir_filter_xxx_1.declare_sample_delay(0)
        self.fec_extended_decoder_0_0_1_0_1_0_0 = fec.extended_decoder(
            decoder_obj_list=pld_dec,
            threading='capillary',
            ann=None,
            puncpat=puncpat,
            integration_period=10000)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            2, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_map_bb_0_0_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(
            15, 0.01, 2, pld_const)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(
            pld_const.arity())
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 100.0, pld_const.arity(), False)
        self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts(
            digital.packet_utils.default_access_code, 4, 'packet_len')
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            pld_const)
        self.custom_corr = correlate_and_delay.corr_and_delay(
            200 * sps, 0, 0.99, sps)
        self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.5, ))
        self.blocks_keep_m_in_n_0_1_1_0 = blocks.keep_m_in_n(
            gr.sizeof_char, 440, 442, 0)
        self.blocks_keep_m_in_n_0_0_2_0_0 = blocks.keep_m_in_n(
            gr.sizeof_char, 1100, 1104, 0)
        self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/it/Desktop/Trasmited/depois.txt', False)
        self.blocks_file_sink_0_0_0_0_2.set_unbuffered(False)
        self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1)
        self.blocks_copy_0.set_enabled(variable_qtgui_check_box_0)
        self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2_0_0_0 = blocks.char_to_float(1, 1)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, -5)
        self.adapt_lms_filter_xx_0_0 = adapt.lms_filter_cc(
            True, 64, 0.0001, 1, 2, True, False, False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.adapt_lms_filter_xx_0_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.adapt_lms_filter_xx_0_0, 1),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0),
                     (self.interp_fir_filter_xxx_1, 0))
        self.connect((self.blocks_char_to_float_0_2_0_0_0, 0),
                     (self.fec_extended_decoder_0_0_1_0_1_0_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_copy_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_keep_m_in_n_0_0_2_0_0, 0),
                     (self.digital_map_bb_0_0_0_0_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0_1_1_0, 0),
                     (self.scrambler_cpp_additive_descrambler_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.blocks_copy_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.custom_corr, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0),
                     (self.qtgui_time_sink_x_1_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_correlate_access_code_xx_ts_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_file_sink_0_0_0_0_2, 0))
        self.connect((self.custom_corr, 1), (self.adapt_lms_filter_xx_0_0, 0))
        self.connect((self.custom_corr, 0), (self.adapt_lms_filter_xx_0_0, 1))
        self.connect((self.custom_corr, 2), (self.blocks_null_sink_1, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0),
                     (self.blocks_keep_m_in_n_0_0_2_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.digital_map_bb_0_0_0_0_0_0, 0),
                     (self.blocks_char_to_float_0_2_0_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0, 0))
        self.connect((self.fec_extended_decoder_0_0_1_0_1_0_0, 0),
                     (self.blocks_keep_m_in_n_0_1_1_0, 0))
        self.connect((self.interp_fir_filter_xxx_1, 0),
                     (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.scrambler_cpp_additive_descrambler_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0_1_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.custom_corr, 1))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
コード例 #56
0
    def __init__(self, fc=629e6, gaindB=23, samp_rate=12.5e6):
        gr.top_block.__init__(self, "Usrp 2Chrx Save")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.gaindB = gaindB
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################
        self.chans = chans = 4096

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_float, chans, 'tcp://*:50001', 100, False, -1)
        self.uhd_usrp_source = uhd.usrp_source(
            ",".join(("addr=10.11.2.61", "master_clock_rate=250e6")),
            uhd.stream_args(
                cpu_format="fc32",
                otw_format="sc16",
                args='',
                channels=list(range(0,2)),
            ),
        )
        self.uhd_usrp_source.set_subdev_spec('A:0 B:0', 0)
        self.uhd_usrp_source.set_time_source('external', 0)
        self.uhd_usrp_source.set_clock_source('external', 0)
        self.uhd_usrp_source.set_center_freq(fc, 0)
        self.uhd_usrp_source.set_gain(gaindB, 0)
        self.uhd_usrp_source.set_antenna('TX/RX', 0)
        self.uhd_usrp_source.set_center_freq(fc, 1)
        self.uhd_usrp_source.set_gain(gaindB, 1)
        self.uhd_usrp_source.set_antenna('TX/RX', 1)
        self.uhd_usrp_source.set_samp_rate(samp_rate)
        self.uhd_usrp_source.set_time_unknown_pps(uhd.time_spec())
        self.fft_vxx_0_0 = fft.fft_vcc(chans, True, window.blackmanharris(chans), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(chans, True, window.blackmanharris(chans), True, 1)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, chans)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, chans)
        self.blocks_interleave_0 = blocks.interleave(gr.sizeof_float*chans, 1)
        self.blocks_integrate_xx_0_0 = blocks.integrate_ff(1000, chans)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(1000, chans)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, 'test.cfile', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(chans)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(chans)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_integrate_xx_0_0, 0))
        self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_interleave_0, 0))
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_interleave_0, 1))
        self.connect((self.blocks_interleave_0, 0), (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.fft_vxx_0_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.uhd_usrp_source, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_usrp_source, 1), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.uhd_usrp_source, 0), (self.blocks_stream_to_vector_0_0, 0))
コード例 #57
0
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Eve")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Eve")
        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", "eve")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.puncpat = puncpat

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.samp_rate_array_MCR = samp_rate_array_MCR = [
            7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000,
            1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052,
            400000, 380952, 200000
        ]
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22
        self.H_dec = H_dec = fec.ldpc_H_matrix(
            '/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist',
            24)
        self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 56
        self.samp_rate = samp_rate = samp_rate_array_MCR[15]

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts)

        self.pld_dec = pld_dec = map(
            (lambda a: fec.ldpc_bit_flip_decoder.make(H_dec.get_base_sptr(), 7)
             ), range(0, 8))
        self.pld_const = pld_const = digital.constellation_rect(([
            0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j
        ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.pld_const.gen_soft_dec_lut(8)
        self.frequencia_usrp = frequencia_usrp = 24e8
        self.MCR = MCR = "master_clock_rate=60e6"

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 56, 200)
        self._variable_qtgui_range_0_1_win = RangeWidget(
            self._variable_qtgui_range_0_1_range,
            self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider",
            float)
        self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 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.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("serial=F5EB09", MCR)),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_center_freq(frequencia_usrp, 0)
        self.uhd_usrp_source_0_0.set_gain(variable_qtgui_range_0_1, 0)
        self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0)
        self.qtgui_time_sink_x_2_0 = qtgui.time_sink_f(
            1024,  #size
            samp_rate,  #samp_rate
            "After CAC",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2_0.set_update_time(0.10)
        self.qtgui_time_sink_x_2_0.set_y_axis(0, 1.5)

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

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

        if not True:
            self.qtgui_time_sink_x_2_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_2_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_2_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_0_win, 2, 2,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "RX USRP",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1_0.set_update_time(0.10)
        self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1)

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

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

        if not True:
            self.qtgui_time_sink_x_1_0.disable_legend()

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

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

        self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 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.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            100 * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(0.10)
        self.qtgui_time_sink_x_0_1.set_y_axis(-1, 256)

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

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

        if not True:
            self.qtgui_time_sink_x_0_1.disable_legend()

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

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

        self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 2, 3,
                                       1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "RX Const",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode(
            qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0_1.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 1,
                                       3, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
            1024,  #size
            "RX Treated",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_0.disable_legend()

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

        self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 100.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(
            pld_const.arity())
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            6.28 / 100.0, pld_const.arity(), False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            pld_const)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            15, 1, 0.01, 2)
        self.cac_cpp_cac_bb_0 = cac_cpp.cac_bb(
            digital.packet_utils.default_access_code, 1)
        self.blocks_repack_bits_bb_0_0_0_1_0 = blocks.repack_bits_bb(
            1, 8, '', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST)
        self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/andre/ELI/1/EVE_55_8000_BRUTO.txt',
            False)
        self.blocks_file_sink_0_0_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1, '/home/andre/ELI/1/EVE_EVM.txt', False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_2_0, 0))
        self.connect((self.blocks_char_to_float_1_0_1, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.cac_cpp_cac_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_char_to_float_1_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0, 0))
        self.connect((self.cac_cpp_cac_bb_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.cac_cpp_cac_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0_1_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_const_sink_x_0_0_0_1, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_time_sink_x_1_0, 0))
コード例 #58
0
ファイル: hd_tx_usrp.py プロジェクト: otilrac/gr-nrsc5
    def __init__(self):
        gr.top_block.__init__(self, "Hd Tx Usrp", catch_exceptions=True)

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 2000000
        self.freq = freq = 87.5e6
        self.audio_rate = audio_rate = 44100

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", '')),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
            '',
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec(0))

        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_gain(70, 0)
        self.rational_resampler_xxx_2 = filter.rational_resampler_ccc(
            interpolation=256, decimation=243, taps=[], fractional_bw=-1.0)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=125, decimation=49, taps=[], fractional_bw=-1.0)
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_ccc(
            interpolation=100, decimation=21, taps=[], fractional_bw=-1.0)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=50, decimation=21, taps=[], fractional_bw=-1.0)
        self.nrsc5_sis_encoder_0 = nrsc5.sis_encoder('ABCD')
        self.nrsc5_psd_encoder_0 = nrsc5.psd_encoder(0, 'Title', 'Artist')
        self.nrsc5_l2_encoder_0 = nrsc5.l2_encoder(1, 0, 146176)
        self.nrsc5_l1_fm_encoder_mp1_0 = nrsc5.l1_fm_encoder(1)
        self.nrsc5_hdc_encoder_0 = nrsc5.hdc_encoder(2, 64000)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(0.1, samp_rate, 80000, 20000, window.WIN_HAMMING,
                            6.76))
        self.fft_vxx_0 = fft.fft_vcc(2048, False, window.rectangular(2048),
                                     True, 1)
        self.blocks_wavfile_source_1 = blocks.wavfile_source(
            'sample_mono.wav', True)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            'sample.wav', True)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 2048)
        self.blocks_vector_source_x_0 = blocks.vector_source_c(
            [math.sin(math.pi / 2 * i / 112)
             for i in range(112)] + [1] * (2048 - 112) +
            [math.cos(math.pi / 2 * i / 112) for i in range(112)], True, 1, [])
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 2048, 2)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.001)
        self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex,
                                                       2160, 4096, 0)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1,
                                           int(audio_rate * 3.5))
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_wfm_tx_0_0 = analog.wfm_tx(
            audio_rate=audio_rate,
            quad_rate=audio_rate * 4,
            tau=75e-6,
            max_dev=75e3,
            fh=-1.0,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_tx_0_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_delay_0, 0), (self.analog_wfm_tx_0_0, 0))
        self.connect((self.blocks_keep_m_in_n_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_keep_m_in_n_0, 0))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.nrsc5_hdc_encoder_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.nrsc5_hdc_encoder_0, 1))
        self.connect((self.blocks_wavfile_source_1, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.nrsc5_hdc_encoder_0, 0),
                     (self.nrsc5_l2_encoder_0, 0))
        self.connect((self.nrsc5_l1_fm_encoder_mp1_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.nrsc5_l2_encoder_0, 0),
                     (self.nrsc5_l1_fm_encoder_mp1_0, 0))
        self.connect((self.nrsc5_psd_encoder_0, 0),
                     (self.nrsc5_l2_encoder_0, 1))
        self.connect((self.nrsc5_sis_encoder_0, 0),
                     (self.nrsc5_l1_fm_encoder_mp1_0, 1))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.rational_resampler_xxx_2, 0))
        self.connect((self.rational_resampler_xxx_2, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
コード例 #59
0
    def __init__(self):
        gr.top_block.__init__(self, "Calibration Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Calibration Example")
        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", "calibration_example_gui_manual")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.speed_of_light = speed_of_light = 299792458
        self.antenna_spacing = antenna_spacing = 0.1
        self.variable_qtgui_chooser_0_1_1 = variable_qtgui_chooser_0_1_1 = 1
        self.variable_qtgui_chooser_0_1_0 = variable_qtgui_chooser_0_1_0 = 0
        self.variable_qtgui_chooser_0_0_0 = variable_qtgui_chooser_0_0_0 = 1
        self.variable_qtgui_chooser_0_0 = variable_qtgui_chooser_0_0 = 0
        self.samp_rate = samp_rate = 100000000/64
        self.gain_rx = gain_rx = 0
        self.center_freq = center_freq = speed_of_light/(2*antenna_spacing)
        self.cal_freq = cal_freq = 1024
        self.Shift_1 = Shift_1 = -4
        self.Shift_0 = Shift_0 = -4
        self.Shift = Shift = -4

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_chooser_0_1_1_options = (1, 0, )
        self._variable_qtgui_chooser_0_1_1_labels = ("Not Started", "Start Save", )
        self._variable_qtgui_chooser_0_1_1_group_box = Qt.QGroupBox("Trigger Data Save")
        self._variable_qtgui_chooser_0_1_1_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._variable_qtgui_chooser_0_1_1_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_1_1_group_box.setLayout(self._variable_qtgui_chooser_0_1_1_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_1_1_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_1_1_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_1_1_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_1_1_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_1_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_1_options.index(i)))
        self._variable_qtgui_chooser_0_1_1_callback(self.variable_qtgui_chooser_0_1_1)
        self._variable_qtgui_chooser_0_1_1_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_1_1(self._variable_qtgui_chooser_0_1_1_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_1_group_box)
        self._variable_qtgui_chooser_0_0_0_options = (0, 1, )
        self._variable_qtgui_chooser_0_0_0_labels = ("Enable", "Disable", )
        self._variable_qtgui_chooser_0_0_0_group_box = Qt.QGroupBox("Distant Transmitter Enable")
        self._variable_qtgui_chooser_0_0_0_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._variable_qtgui_chooser_0_0_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_0_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_0_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_0_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_0_options.index(i)))
        self._variable_qtgui_chooser_0_0_0_callback(self.variable_qtgui_chooser_0_0_0)
        self._variable_qtgui_chooser_0_0_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_0_0(self._variable_qtgui_chooser_0_0_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_0_group_box)
        self._variable_qtgui_chooser_0_0_options = (0, 1, )
        self._variable_qtgui_chooser_0_0_labels = ("Enable", "Disable", )
        self._variable_qtgui_chooser_0_0_group_box = Qt.QGroupBox("Source Enable")
        self._variable_qtgui_chooser_0_0_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._variable_qtgui_chooser_0_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_options.index(i)))
        self._variable_qtgui_chooser_0_0_callback(self.variable_qtgui_chooser_0_0)
        self._variable_qtgui_chooser_0_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_0(self._variable_qtgui_chooser_0_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_group_box)
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "Input")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "Post Gain Correct")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Post Phase Correct")
        self.top_layout.addWidget(self.tab)
        self._Shift_1_range = Range(-4, 4, 0.01, -4, 200)
        self._Shift_1_win = RangeWidget(self._Shift_1_range, self.set_Shift_1, "Shift", "counter_slider", float)
        self.top_layout.addWidget(self._Shift_1_win)
        self._Shift_0_range = Range(-4, 4, 0.01, -4, 200)
        self._Shift_0_win = RangeWidget(self._Shift_0_range, self.set_Shift_0, "Shift", "counter_slider", float)
        self.top_layout.addWidget(self._Shift_0_win)
        self._Shift_range = Range(-4, 4, 0.01, -4, 200)
        self._Shift_win = RangeWidget(self._Shift_range, self.set_Shift, "Shift", "counter_slider", float)
        self.top_layout.addWidget(self._Shift_win)
        self._variable_qtgui_chooser_0_1_0_options = (1, 0, )
        self._variable_qtgui_chooser_0_1_0_labels = ("Stop", "Running", )
        self._variable_qtgui_chooser_0_1_0_group_box = Qt.QGroupBox("Sync System")
        self._variable_qtgui_chooser_0_1_0_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._variable_qtgui_chooser_0_1_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_1_0_group_box.setLayout(self._variable_qtgui_chooser_0_1_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_1_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_1_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_1_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_1_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_0_options.index(i)))
        self._variable_qtgui_chooser_0_1_0_callback(self.variable_qtgui_chooser_0_1_0)
        self._variable_qtgui_chooser_0_1_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_1_0(self._variable_qtgui_chooser_0_1_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_0_group_box)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(("addr0=192.168.70.2,addr1=192.168.20.2,addr2=192.168.30.2,addr3=192.168.50.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(4),
        	),
        )
        self.uhd_usrp_source_0_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0_0.set_time_source("external", 0)
        self.uhd_usrp_source_0_0.set_clock_source("external", 1)
        self.uhd_usrp_source_0_0.set_time_source("external", 1)
        self.uhd_usrp_source_0_0.set_clock_source("external", 2)
        self.uhd_usrp_source_0_0.set_time_source("external", 2)
        self.uhd_usrp_source_0_0.set_clock_source("external", 3)
        self.uhd_usrp_source_0_0.set_time_source("external", 3)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 0)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 1)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 1)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 2)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 2)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 3)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 3)
        self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.80.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0_0_0.set_gain(30, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.40.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_0.set_clock_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_time_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0_0.set_gain(10, 0)
        self.save_data_hier_0 = save_data_hier(
            keep=1,
            samples=2**22,
            skips=2**18,
            vec_size=1,
        )
        self.real_time_scope_hier_0_0_0 = real_time_scope_hier(
            npoints=3000,
            samp_rate=samp_rate,
        )
        self.tab_layout_2.addWidget(self.real_time_scope_hier_0_0_0)
        self.real_time_scope_hier_0 = real_time_scope_hier(
            npoints=3000,
            samp_rate=samp_rate,
        )
        self.tab_layout_0.addWidget(self.real_time_scope_hier_0)
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((complex(numpy.cos(Shift_1),numpy.sin(Shift_1)), ))
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((complex(numpy.cos(Shift_0),numpy.sin(Shift_0)), ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((complex(numpy.cos(Shift),numpy.sin(Shift)), ))
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_1_1), 1000)
        self.blks2_valve_0_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0_0))
        self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0))
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.save_data_hier_0, 'Trigger'))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blks2_valve_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_valve_0_0, 0))    
        self.connect((self.blks2_valve_0, 0), (self.uhd_usrp_sink_0_0, 0))    
        self.connect((self.blks2_valve_0_0, 0), (self.uhd_usrp_sink_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.real_time_scope_hier_0_0_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.save_data_hier_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.real_time_scope_hier_0_0_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.save_data_hier_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.real_time_scope_hier_0_0_0, 3))    
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.save_data_hier_0, 3))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 2), (self.blocks_multiply_const_vxx_0_1, 0))    
        self.connect((self.uhd_usrp_source_0_0, 3), (self.blocks_multiply_const_vxx_0_2, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.real_time_scope_hier_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.real_time_scope_hier_0, 1))    
        self.connect((self.uhd_usrp_source_0_0, 2), (self.real_time_scope_hier_0, 2))    
        self.connect((self.uhd_usrp_source_0_0, 3), (self.real_time_scope_hier_0, 3))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.real_time_scope_hier_0_0_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.save_data_hier_0, 0))    
コード例 #60
0
    def __init__(self):
        gr.top_block.__init__(self, "FM Sender")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("FM Sender")
        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", "fm_transmitter")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.osr_rf = osr_rf = 4
        self.osr_mod = osr_mod = 5
        self.fs_file = fs_file = 48000
        self.tx_gain_db = tx_gain_db = 0.8
        self.outbuffer = outbuffer = 10
        self.n_filter_delay = n_filter_delay = 289 // 2
        self.gain_rds = gain_rds = 0.05
        self.gain_pilot = gain_pilot = 0.05
        self.gain_mono = gain_mono = 0.3
        self.gain_lrdiff = gain_lrdiff = 0.5
        self.gain_hinz = gain_hinz = 0.05
        self.fs_rf = fs_rf = fs_file * osr_mod * osr_rf
        self.fs_mod = fs_mod = fs_file * osr_mod
        self.fc_pirate = fc_pirate = 99e6

        ##################################################
        # Blocks
        ##################################################
        self._tx_gain_db_range = Range(0, 1, 0.01, 0.8, 200)
        self._tx_gain_db_win = RangeWidget(self._tx_gain_db_range,
                                           self.set_tx_gain_db, 'tx_gain_db',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_gain_db_win, 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.qtgui_tab_widget_0 = Qt.QTabWidget()
        self.qtgui_tab_widget_0_widget_0 = Qt.QWidget()
        self.qtgui_tab_widget_0_layout_0 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_0)
        self.qtgui_tab_widget_0_grid_layout_0 = Qt.QGridLayout()
        self.qtgui_tab_widget_0_layout_0.addLayout(
            self.qtgui_tab_widget_0_grid_layout_0)
        self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_0,
                                       'Tab 0')
        self.qtgui_tab_widget_0_widget_1 = Qt.QWidget()
        self.qtgui_tab_widget_0_layout_1 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_1)
        self.qtgui_tab_widget_0_grid_layout_1 = Qt.QGridLayout()
        self.qtgui_tab_widget_0_layout_1.addLayout(
            self.qtgui_tab_widget_0_grid_layout_1)
        self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_1,
                                       'Tab 1')
        self.qtgui_tab_widget_0_widget_2 = Qt.QWidget()
        self.qtgui_tab_widget_0_layout_2 = Qt.QBoxLayout(
            Qt.QBoxLayout.TopToBottom, self.qtgui_tab_widget_0_widget_2)
        self.qtgui_tab_widget_0_grid_layout_2 = Qt.QGridLayout()
        self.qtgui_tab_widget_0_layout_2.addLayout(
            self.qtgui_tab_widget_0_grid_layout_2)
        self.qtgui_tab_widget_0.addTab(self.qtgui_tab_widget_0_widget_2,
                                       'Tab 2')
        self.top_grid_layout.addWidget(self.qtgui_tab_widget_0, 5, 0, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._n_filter_delay_range = Range(0, 400, 1, 289 // 2, 200)
        self._n_filter_delay_win = RangeWidget(self._n_filter_delay_range,
                                               self.set_n_filter_delay,
                                               'n_filter_delay',
                                               "counter_slider", int)
        self.top_grid_layout.addWidget(self._n_filter_delay_win, 9, 0, 1, 1)
        for r in range(9, 10):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain_rds_range = Range(0, 1, 0.05, 0.05, 200)
        self._gain_rds_win = RangeWidget(self._gain_rds_range,
                                         self.set_gain_rds, 'gain_rds',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_rds_win, 8, 0, 1, 1)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain_pilot_range = Range(0, 1, 0.05, 0.05, 200)
        self._gain_pilot_win = RangeWidget(self._gain_pilot_range,
                                           self.set_gain_pilot, 'gain_pilot',
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_pilot_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._gain_mono_range = Range(0, 1, 0.05, 0.3, 200)
        self._gain_mono_win = RangeWidget(self._gain_mono_range,
                                          self.set_gain_mono, 'gain_mono',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_mono_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._gain_lrdiff_range = Range(0, 1, 0.05, 0.5, 200)
        self._gain_lrdiff_win = RangeWidget(self._gain_lrdiff_range,
                                            self.set_gain_lrdiff,
                                            'gain_lrdiff', "counter_slider",
                                            float)
        self.top_grid_layout.addWidget(self._gain_lrdiff_win, 2, 0, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._gain_hinz_range = Range(0, 0.5, 0.05, 0.05, 200)
        self._gain_hinz_win = RangeWidget(self._gain_hinz_range,
                                          self.set_gain_hinz, 'gain_hinz',
                                          "counter_slider", float)
        self.top_grid_layout.addWidget(self._gain_hinz_win, 4, 0, 1, 1)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.uhd_usrp_sink_1 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
            '',
        )
        self.uhd_usrp_sink_1.set_center_freq(fc_pirate, 0)
        self.uhd_usrp_sink_1.set_normalized_gain(tx_gain_db, 0)
        self.uhd_usrp_sink_1.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_1.set_bandwidth(200e3, 0)
        self.uhd_usrp_sink_1.set_samp_rate(fs_rf)
        self.uhd_usrp_sink_1.set_time_unknown_pps(uhd.time_spec())
        self.rds_encoder_0 = rds.encoder(0, 20, True, 'PIRAT 17', 47.11e6,
                                         True, False, 13, 3, 147,
                                         'SAALFELDEN TESTING')

        self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_fff(
            interpolation=osr_mod, decimation=1, taps=None, fractional_bw=None)
        self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff(
            interpolation=osr_mod, decimation=1, taps=None, fractional_bw=None)
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
            interpolation=osr_mod, decimation=1, taps=None, fractional_bw=None)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=osr_rf, decimation=1, taps=None, fractional_bw=None)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            4096 * 2,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            fs_mod,  #bw
            "fmChannelData",  #name
            1)
        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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(0.1)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        self.qtgui_freq_sink_x_0.set_plot_pos_half(not False)

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

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.qtgui_tab_widget_0_layout_0.addWidget(
            self._qtgui_freq_sink_x_0_win)
        self.low_pass_filter_0 = filter.interp_fir_filter_fff(
            1, firdes.low_pass(1, fs_mod, 2.5e3, .5e3, firdes.WIN_HAMMING,
                               6.76))
        self.low_pass_filter_0.set_max_output_buffer(10)
        self.gr_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2)
        self.gr_unpack_k_bits_bb_0.set_max_output_buffer(10)
        self.gr_sig_source_x_0_0 = analog.sig_source_f(fs_mod,
                                                       analog.GR_COS_WAVE,
                                                       57e3, 1, 0, 0)
        self.gr_multiply_xx_0 = blocks.multiply_vff(1)
        self.gr_multiply_xx_0.set_max_output_buffer(10)
        self.gr_map_bb_1 = digital.map_bb([1, 2])
        self.gr_map_bb_1.set_max_output_buffer(10)
        self.gr_map_bb_0 = digital.map_bb([-1, 1])
        self.gr_map_bb_0.set_max_output_buffer(10)
        self.gr_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.gr_diff_encoder_bb_0.set_max_output_buffer(10)
        self.gr_char_to_float_0 = blocks.char_to_float(1, 1)
        self.gr_char_to_float_0.set_max_output_buffer(10)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1,
                                             int(fs_mod / 2.375 / 1000))
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_xx_0_2 = blocks.multiply_const_ff(
            gain_hinz, 1)
        self.blocks_multiply_const_xx_0_0_0 = blocks.multiply_const_ff(
            gain_pilot, 1)
        self.blocks_multiply_const_xx_0_0 = blocks.multiply_const_ff(
            gain_lrdiff, 1)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_ff(
            gain_mono, 1)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_ff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(gain_rds)
        self.blocks_multiply_const_vxx_0_0.set_max_output_buffer(10)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1,
                                             n_filter_delay)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, n_filter_delay)
        self.blocks_add_xx_0_0 = blocks.add_vff(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.band_pass_filter_1_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, fs_mod, 30, 15e3, 100, firdes.WIN_HAMMING,
                             6.76))
        self.band_pass_filter_1 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, fs_mod, 30, 15e3, 100, firdes.WIN_HAMMING,
                             6.76))
        self.band_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.band_pass(1, fs_mod, 23e3, 53e3, 2e3, firdes.WIN_HAMMING,
                             6.76))
        self.band_pass_filter_0.set_block_alias("filter_bp_lrdiff")
        self.audio_source_0_0 = audio.source(48000, 'pulse_monitor', False)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            fs_mod, analog.GR_COS_WAVE, 19e3, 1, 0, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            fs_mod, analog.GR_COS_WAVE, 38e3, 1, 0, 0)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            75e3 / fs_mod * 2 * math.pi)
        self.analog_fm_preemph_0_0 = analog.fm_preemph(fs=fs_file,
                                                       tau=50e-6,
                                                       fh=-1.0)
        self.analog_fm_preemph_0 = analog.fm_preemph(fs=fs_file,
                                                     tau=50e-6,
                                                     fh=-1.0)
        self.analog_const_source_x_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0),
                     (self.rational_resampler_xxx_0_0_0_0, 0))
        self.connect((self.analog_fm_preemph_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_fm_preemph_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_fm_preemph_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_fm_preemph_0_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.analog_frequency_modulator_fc_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        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_delay_0, 0))
        self.connect((self.audio_source_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.audio_source_0_0, 1),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.blocks_multiply_const_xx_0_0, 0))
        self.connect((self.band_pass_filter_1, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.band_pass_filter_1_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_const_xx_0_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_multiply_const_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.analog_fm_preemph_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_add_xx_0_0, 4))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.analog_fm_preemph_0_0, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.blocks_multiply_const_xx_0_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_multiply_const_xx_0_0_0, 0),
                     (self.blocks_add_xx_0_0, 2))
        self.connect((self.blocks_multiply_const_xx_0_2, 0),
                     (self.blocks_add_xx_0_0, 3))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.rational_resampler_xxx_0_0_0, 0))
        self.connect((self.gr_char_to_float_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.gr_diff_encoder_bb_0, 0), (self.gr_map_bb_1, 0))
        self.connect((self.gr_map_bb_0, 0), (self.gr_char_to_float_0, 0))
        self.connect((self.gr_map_bb_1, 0), (self.gr_unpack_k_bits_bb_0, 0))
        self.connect((self.gr_multiply_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.gr_sig_source_x_0_0, 0), (self.gr_multiply_xx_0, 0))
        self.connect((self.gr_unpack_k_bits_bb_0, 0), (self.gr_map_bb_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.gr_multiply_xx_0, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.uhd_usrp_sink_1, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.band_pass_filter_1, 0))
        self.connect((self.rational_resampler_xxx_0_0_0, 0),
                     (self.band_pass_filter_1_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_0_0, 0),
                     (self.blocks_multiply_const_xx_0_2, 0))
        self.connect((self.rds_encoder_0, 0), (self.gr_diff_encoder_bb_0, 0))