def __init__(self):
        gr.top_block.__init__(self, "Msod Sslsensor N210")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Msod Sslsensor N210")
        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", "MSOD_SSLSensor_N210")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 12.5e6
        self.fft_size = fft_size = 625
        self.num_ch = num_ch = 56
        self.mywindow = mywindow = window.blackmanharris(fft_size)
        self.hz_per_bin = hz_per_bin = samp_rate / fft_size
        self.bandwidth = bandwidth = 10.08e6
        self.window_power = window_power = sum(map(lambda x: x*x, mywindow))
        self.meas_interval = meas_interval = 1e-3
        self.impedance = impedance = 50.0
        self.channel_bw = channel_bw = hz_per_bin * round(bandwidth / num_ch / hz_per_bin)
        self.device3 = variable_uhd_device3_0 = ettus.device3(uhd.device_addr_t( ",".join(('type=x300, addr=usrp02', "")) ))
        self.rx_gain = rx_gain = 0
        self.meas_period = meas_period = max(1, int(round(meas_interval * samp_rate / fft_size)))
        self.dest_host = dest_host = "129.6.142.103"
        self.center_freq = center_freq = 724e6
        self.Vsq2W_dB = Vsq2W_dB = -10.0 * math.log10(fft_size * int(window_power) * impedance)
        self.ActualBW = ActualBW = channel_bw * num_ch

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = (12.5e6, 15.36e6, 7.68e6, 3.84e6, 1.92e6, )
        self._samp_rate_labels = ('12.5e6', '15.36e6', '7.68e6', '3.84e6', '1.92e6', )
        self._samp_rate_group_box = Qt.QGroupBox('samp_rate')
        self._samp_rate_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._samp_rate_button_group = variable_chooser_button_group()
        self._samp_rate_group_box.setLayout(self._samp_rate_box)
        for i, label in enumerate(self._samp_rate_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._samp_rate_box.addWidget(radio_button)
        	self._samp_rate_button_group.addButton(radio_button, i)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_button_group.buttonClicked[int].connect(
        	lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_group_box)
        self._rx_gain_range = Range(0, 31.5, 0.5, 0, 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._num_ch_options = (56, 50, 25, 15, 8, )
        self._num_ch_labels = ('56', '50', '25', '15', '8', )
        self._num_ch_group_box = Qt.QGroupBox('num_ch')
        self._num_ch_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._num_ch_button_group = variable_chooser_button_group()
        self._num_ch_group_box.setLayout(self._num_ch_box)
        for i, label in enumerate(self._num_ch_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._num_ch_box.addWidget(radio_button)
        	self._num_ch_button_group.addButton(radio_button, i)
        self._num_ch_callback = lambda i: Qt.QMetaObject.invokeMethod(self._num_ch_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._num_ch_options.index(i)))
        self._num_ch_callback(self.num_ch)
        self._num_ch_button_group.buttonClicked[int].connect(
        	lambda i: self.set_num_ch(self._num_ch_options[i]))
        self.top_layout.addWidget(self._num_ch_group_box)
        self._fft_size_options = (625, 1024, 512, 256, 128, )
        self._fft_size_labels = ('625', '1024', '512', '256', '128', )
        self._fft_size_tool_bar = Qt.QToolBar(self)
        self._fft_size_tool_bar.addWidget(Qt.QLabel('fft_size'+": "))
        self._fft_size_combo_box = Qt.QComboBox()
        self._fft_size_tool_bar.addWidget(self._fft_size_combo_box)
        for label in self._fft_size_labels: self._fft_size_combo_box.addItem(label)
        self._fft_size_callback = lambda i: Qt.QMetaObject.invokeMethod(self._fft_size_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._fft_size_options.index(i)))
        self._fft_size_callback(self.fft_size)
        self._fft_size_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_fft_size(self._fft_size_options[i]))
        self.top_layout.addWidget(self._fft_size_tool_bar)
        self._center_freq_options = (709.01e6, 782e6, 724e6, )
        self._center_freq_labels = ('AT&T', 'Verizon', 'ChannelEmulator', )
        self._center_freq_tool_bar = Qt.QToolBar(self)
        self._center_freq_tool_bar.addWidget(Qt.QLabel('center_freq'+": "))
        self._center_freq_combo_box = Qt.QComboBox()
        self._center_freq_tool_bar.addWidget(self._center_freq_combo_box)
        for label in self._center_freq_labels: self._center_freq_combo_box.addItem(label)
        self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._center_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._center_freq_options.index(i)))
        self._center_freq_callback(self.center_freq)
        self._center_freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_center_freq(self._center_freq_options[i]))
        self.top_layout.addWidget(self._center_freq_tool_bar)
        self._bandwidth_options = (10.08e6, 9e6, 4.5e6, 2.7e6, 1.08e6, )
        self._bandwidth_labels = ('10.08e6', '9e6', '4.5e6', '2.7e6', '1.08e6', )
        self._bandwidth_tool_bar = Qt.QToolBar(self)
        self._bandwidth_tool_bar.addWidget(Qt.QLabel('bandwidth'+": "))
        self._bandwidth_combo_box = Qt.QComboBox()
        self._bandwidth_tool_bar.addWidget(self._bandwidth_combo_box)
        for label in self._bandwidth_labels: self._bandwidth_combo_box.addItem(label)
        self._bandwidth_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bandwidth_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._bandwidth_options.index(i)))
        self._bandwidth_callback(self.bandwidth)
        self._bandwidth_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_bandwidth(self._bandwidth_options[i]))
        self.top_layout.addWidget(self._bandwidth_tool_bar)
        self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio(
            self.device3,
            uhd.stream_args( # Tx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="", # empty
            ),
            uhd.stream_args( # Rx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
        	args='',
            ),
            1, -1
        )
        self.uhd_rfnoc_streamer_radio_0.set_rate(samp_rate)
        for i in xrange(1):
            self.uhd_rfnoc_streamer_radio_0.set_rx_freq(center_freq, i)
            self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain, i)
            self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("RX2", i)
            self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True, i)
        self.spectrum_latency_jsonfile_sink_0 = spectrum_latency.jsonfile_sink(num_ch, "/home/nae/Spectrum-Sensors/N210/Capture.N210/10-25-2016", "/raid/nae/gnuradio/src/gr-spectrum_latency/examples/utils/sensor.loc", "/raid/nae/gnuradio/src/gr-spectrum_latency/examples/utils/sensor.sys", "F37258", "12345", center_freq, bandwidth, meas_interval, 0, samp_rate, False)
        self.spectrum_latency_bin_statistics_0 = spectrum_latency.bin_statistics(num_ch, meas_period)
        self.spectrum_latency_bin_aggregator_0 = spectrum_latency.bin_aggregator(fft_size, num_ch, samp_rate, fft_size, center_freq, ActualBW, channel_bw, [0] * fft_size)
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (mywindow), True, 1)
        self._dest_host_options = ("pwct1.ctl.nist.gov", "129.6.142.103", "129.6.142.181", "pwct5.ctl.nist.gov", )
        self._dest_host_labels = ('pwct1', 'NEO_VM', 'pwct5Desktop', 'Pwct5', )
        self._dest_host_tool_bar = Qt.QToolBar(self)
        self._dest_host_tool_bar.addWidget(Qt.QLabel(dest_host+": "))
        self._dest_host_combo_box = Qt.QComboBox()
        self._dest_host_tool_bar.addWidget(self._dest_host_combo_box)
        for label in self._dest_host_labels: self._dest_host_combo_box.addItem(label)
        self._dest_host_callback = lambda i: Qt.QMetaObject.invokeMethod(self._dest_host_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._dest_host_options.index(i)))
        self._dest_host_callback(self.dest_host)
        self._dest_host_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_dest_host(self._dest_host_options[i]))
        self.top_layout.addWidget(self._dest_host_tool_bar)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, num_ch, 30.0 + Vsq2W_dB)
        self.blocks_float_to_char_0 = blocks.float_to_char(num_ch, 1.0)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_size)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.spectrum_latency_bin_aggregator_0, 0))    
        self.connect((self.blocks_float_to_char_0, 0), (self.spectrum_latency_jsonfile_sink_0, 0))    
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_float_to_char_0, 0))    
        self.connect((self.blocks_stream_to_vector_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.spectrum_latency_bin_aggregator_0, 0), (self.spectrum_latency_bin_statistics_0, 0))    
        self.connect((self.spectrum_latency_bin_statistics_0, 0), (self.blocks_nlog10_ff_0, 0))    
        self.connect((self.uhd_rfnoc_streamer_radio_0, 0), (self.blocks_stream_to_vector_0, 0))    
Example #2
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.device3 = variable_uhd_device3_0 = ettus.device3(
            uhd.device_addr_t(",".join(("type=x300", "addr=192.168.10.2"))))
        self.samp_rate = samp_rate = 20e6

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.uhd_rfnoc_streamer_schmidlcox_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(  # TX Stream Args
                cpu_format="fc32",  # TODO: This must be made an option
                otw_format="sc16",
                channels=(0, ),
                args="",
            ),
            uhd.stream_args(  # RX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                channels=(0, ),
                args="",
            ),
            "SchmidlCox",
            -1,
            -1,
        )
        self.uhd_rfnoc_streamer_schmidlcox_0.set_register(0x10,
                                                          64)  # Frame length
        self.uhd_rfnoc_streamer_schmidlcox_0.set_register(0x11,
                                                          16)  # CP length
        self.uhd_rfnoc_streamer_schmidlcox_0.set_register(
            0x12, 22)  # samples to wait after trigger
        self.uhd_rfnoc_streamer_schmidlcox_0.set_register(
            0x13, 2)  # max number of frames to process
        self.uhd_rfnoc_streamer_fft_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(  # TX Stream Args
                cpu_format="fc32",  # TODO: This must be made an option
                otw_format="sc16",
                args="spp=64,magnitude_out=0",
            ),
            uhd.stream_args(  # RX Stream Args
                cpu_format="fc32",  # TODO: This must be made an option
                otw_format="sc16",
                args="",
            ),
            "FFT",
            -1,
            -1,
        )
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(
            gr.sizeof_gr_complex * 1, 64)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            "/home/julian/git/ofdm-sync/octave-sym/test-float.bin", True)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1, "/home/julian/Desktop/output.bin", False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0),
                     (self.wxgui_scopesink2_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.uhd_rfnoc_streamer_schmidlcox_0, 0))
        self.connect((self.uhd_rfnoc_streamer_fft_0, 0),
                     (self.blocks_vector_to_stream_0, 0))
        self.device3.connect(
            self.uhd_rfnoc_streamer_schmidlcox_0.get_block_id(), 0,
            self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0)
    def __init__(self):
        gr.top_block.__init__(self, "Rfnoc Fft Vectoriir")

        ##################################################
        # Variables
        ##################################################
        self.alpha = alpha = 0.986
        self.seconds = seconds = 5
        self.samp_rate = samp_rate = 40e6
        self.rf_gain = rf_gain = 0
        self.num_points = num_points = 512
        self.hard_coded_sample_count = hard_coded_sample_count = 2883584
        self.freq = freq = 2440e6
        self.device3 = device3 = ettus.device3(uhd.device_addr_t( ",".join(('type=e3x0', "fpga=/home/root/usrp_e310_fpga_RFNOC_sg3.bit")) ))
        self.decim_rate = decim_rate = 18
        self.beta = beta = 1-alpha

        ##################################################
        # Blocks
        ##################################################
        self.uhd_rfnoc_streamer_vector_iir_0 = ettus.rfnoc_generic(
              self.device3,
              uhd.stream_args( # TX Stream Args
                  cpu_format="fc32",
                  otw_format="sc16",
                  args="spp={},alpha={},beta={}".format(num_points, alpha, beta),
              ),
              uhd.stream_args( # TX Stream Args
                  cpu_format="fc32",
                  otw_format="sc16",
                  args="spp={},alpha={},beta={}".format(num_points, alpha, beta),
              ),
              "VectorIIR", -1, -1,
        )
        self.uhd_rfnoc_streamer_vector_iir_0.set_arg("alpha", alpha)
        self.uhd_rfnoc_streamer_vector_iir_0.set_arg("beta",  beta)

        self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio(
            self.device3,
            uhd.stream_args( # Tx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="", # empty
            ),
            uhd.stream_args( # Rx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
          args='spp=512',
            ),
            0, -1
        )
        self.uhd_rfnoc_streamer_radio_0.set_rate(samp_rate)

        self.uhd_rfnoc_streamer_radio_0.set_rx_freq(freq, 0)
        self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rf_gain, 0)
        self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True, 0)


        self.uhd_rfnoc_streamer_radio_0.set_rx_bandwidth(40e6, 0)

        if "RX2":
            self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("RX2", 0)


        self.uhd_rfnoc_streamer_radio_0.set_clock_source("internal")
        self.uhd_rfnoc_streamer_keep_one_in_n_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args( # TX Stream Args
                cpu_format="fc32", # TODO: This must be made an option
                otw_format="sc16",
                args="n="+str(decim_rate),
            ),
            uhd.stream_args( # RX Stream Args
                cpu_format="fc32", # TODO: This must be made an option
                otw_format="sc16",
                args="",
            ),
            "KeepOneInN", -1, -1,
        )
        self.uhd_rfnoc_streamer_fft_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args( # TX Stream Args
                cpu_format="fc32", # TODO: This must be made an option
                otw_format="sc16",
                args="spp={}".format(num_points), # Need to set the FFT size here, or it won't go into the GR IO signature
            ),
            uhd.stream_args( # RX Stream Args
                cpu_format="fc32", # TODO: This must be made an option
                otw_format="sc16",
                args="",
            ),
            "FFT", -1, -1,
        )
        self.uhd_rfnoc_streamer_fft_0.set_arg("direction", "forward")
        self.uhd_rfnoc_streamer_fft_0.set_arg("scaling", 1000)
        self.uhd_rfnoc_streamer_fft_0.set_arg("shift", "normal")
        self.uhd_rfnoc_streamer_fft_0.set_arg("magnitude_out", "COMPLEX")

        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, hard_coded_sample_count)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/root/test_data', False)
        self.blocks_file_sink_0.set_unbuffered(True)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_rfnoc_streamer_keep_one_in_n_0, 0), (self.blocks_head_0, 0))
        self.device3.connect(self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0, self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0)
        self.device3.connect(self.uhd_rfnoc_streamer_radio_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0)
        self.device3.connect(self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0, self.uhd_rfnoc_streamer_keep_one_in_n_0.get_block_id(), 0)
Example #4
0
    def __init__(self):
        gr.top_block.__init__(self, "Msod Sslsensor X310 Rfnoc")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Msod Sslsensor X310 Rfnoc")
        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", "MSOD_SSLSensor_X310_RFNoC")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.fft_size = fft_size = 256
        self.num_ch = num_ch = 50
        self.hz_per_bin = hz_per_bin = samp_rate / fft_size
        self.bandwidth = bandwidth = 9e6
        self.meas_interval = meas_interval = 1e-3
        self.channel_bw = channel_bw = hz_per_bin * round(
            bandwidth / num_ch / hz_per_bin)
        self.device3 = variable_uhd_device3_0 = ettus.device3(
            uhd.device_addr_t(",".join(("type=x300", "addr=usrp0"))))
        self.rx_gain = rx_gain = 0
        self.meas_period = meas_period = max(
            1, int(round(meas_interval * samp_rate / fft_size)))
        self.impedance = impedance = 50.0
        self.dest_host = dest_host = "129.6.142.138"
        self.center_freq = center_freq = 724e6
        self.ActualBW = ActualBW = channel_bw * num_ch

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = (
            10e6,
            25e6,
            12.5e6,
            3.84e6,
            5e5,
        )
        self._samp_rate_labels = (
            "10e6",
            "25e6",
            "12.5e6",
            "3.84e6",
            "5e5",
        )
        self._samp_rate_group_box = Qt.QGroupBox("samp_rate")
        self._samp_rate_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._samp_rate_button_group = variable_chooser_button_group()
        self._samp_rate_group_box.setLayout(self._samp_rate_box)
        for i, label in enumerate(self._samp_rate_labels):
            radio_button = Qt.QRadioButton(label)
            self._samp_rate_box.addWidget(radio_button)
            self._samp_rate_button_group.addButton(radio_button, i)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_button_group.buttonClicked[int].connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_group_box)
        self._rx_gain_range = Range(0, 31.5, 0.5, 0, 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._num_ch_options = (
            56,
            50,
            25,
            15,
            8,
        )
        self._num_ch_labels = (
            "56",
            "50",
            "25",
            "15",
            "8",
        )
        self._num_ch_group_box = Qt.QGroupBox("num_ch")
        self._num_ch_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._num_ch_button_group = variable_chooser_button_group()
        self._num_ch_group_box.setLayout(self._num_ch_box)
        for i, label in enumerate(self._num_ch_labels):
            radio_button = Qt.QRadioButton(label)
            self._num_ch_box.addWidget(radio_button)
            self._num_ch_button_group.addButton(radio_button, i)
        self._num_ch_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._num_ch_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._num_ch_options.index(i)))
        self._num_ch_callback(self.num_ch)
        self._num_ch_button_group.buttonClicked[int].connect(
            lambda i: self.set_num_ch(self._num_ch_options[i]))
        self.top_layout.addWidget(self._num_ch_group_box)
        self._fft_size_options = (
            2048,
            1024,
            512,
            256,
            128,
        )
        self._fft_size_labels = (
            "2048",
            "1024",
            "512",
            "256",
            "128",
        )
        self._fft_size_tool_bar = Qt.QToolBar(self)
        self._fft_size_tool_bar.addWidget(Qt.QLabel("fft_size" + ": "))
        self._fft_size_combo_box = Qt.QComboBox()
        self._fft_size_tool_bar.addWidget(self._fft_size_combo_box)
        for label in self._fft_size_labels:
            self._fft_size_combo_box.addItem(label)
        self._fft_size_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._fft_size_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._fft_size_options.index(i)))
        self._fft_size_callback(self.fft_size)
        self._fft_size_combo_box.currentIndexChanged.connect(
            lambda i: self.set_fft_size(self._fft_size_options[i]))
        self.top_layout.addWidget(self._fft_size_tool_bar)
        self._center_freq_options = (
            709.01e6,
            782e6,
            724e6,
        )
        self._center_freq_labels = (
            "AT&T",
            "Verizon",
            "ChannelEmulator",
        )
        self._center_freq_tool_bar = Qt.QToolBar(self)
        self._center_freq_tool_bar.addWidget(Qt.QLabel("center_freq" + ": "))
        self._center_freq_combo_box = Qt.QComboBox()
        self._center_freq_tool_bar.addWidget(self._center_freq_combo_box)
        for label in self._center_freq_labels:
            self._center_freq_combo_box.addItem(label)
        self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._center_freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._center_freq_options.index(i)))
        self._center_freq_callback(self.center_freq)
        self._center_freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_center_freq(self._center_freq_options[i]))
        self.top_layout.addWidget(self._center_freq_tool_bar)
        self.uhd_rfnoc_streamer_vector_iir_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(  # TX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="spp={},alpha={},beta={}".format(fft_size, 0.984375,
                                                      0.015625),
            ),
            uhd.stream_args(  # TX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="spp={},alpha={},beta={}".format(fft_size, 0.984375,
                                                      0.015625),
            ),
            "VectorIIR",
            -1,
            -1,
        )
        self.uhd_rfnoc_streamer_vector_iir_0.set_arg("alpha", 0.984375)
        self.uhd_rfnoc_streamer_vector_iir_0.set_arg("beta", 0.015625)

        self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio(
            self.device3,
            uhd.stream_args(  # Tx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="",  # empty
            ),
            uhd.stream_args(  # Rx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="spp=256",
            ),
            0,
            -1)
        self.uhd_rfnoc_streamer_radio_0.set_rx_freq(center_freq)
        self.uhd_rfnoc_streamer_radio_0.set_rx_rate(samp_rate)
        self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain)
        self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("TX/RX")
        self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True)
        self.uhd_rfnoc_streamer_logpwr_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(  # TX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(
                    num_ch, "" if num_ch == 1 else "spp={0}".format(num_ch)),
            ),
            uhd.stream_args(  # RX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(
                    num_ch, "" if num_ch == 1 else "spp={0}".format(num_ch)),
            ),
            "LogPwr",
            -1,
            -1,
        )
        self.uhd_rfnoc_streamer_fifo_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(  # TX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(
                    fft_size,
                    "" if fft_size == 1 else "spp={0}".format(fft_size)),
            ),
            uhd.stream_args(  # RX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(
                    fft_size,
                    "" if fft_size == 1 else "spp={0}".format(fft_size)),
            ),
            "FIFO",
            -1,
            -1,
        )
        self.uhd_rfnoc_streamer_fft_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(  # TX Stream Args
                cpu_format="fc32",  # TODO: This must be made an option
                otw_format="sc16",
                args="spp={},magnitude_out={}".format(256, "COMPLEX"),
            ),
            uhd.stream_args(  # RX Stream Args
                cpu_format="fc32",  # TODO: This must be made an option
                otw_format="sc16",
                args="",
            ),
            "FFT",
            -1,
            -1,
        )
        self.uhd_rfnoc_streamer_bin_aggr_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(
                cpu_format="fc32",  # TODO: This must be made an option
                otw_format="sc16",
                args=""),
            uhd.stream_args(
                cpu_format="fc32",  # TODO: This must be made an option
                otw_format="sc16",
                args="",
            ),
            "BinAggr",
            -1,
            -1,
        )
        self.msod_sensor_jsonfile_sink_0 = msod_sensor.jsonfile_sink(
            num_ch, "/home/nae/capture/capture_X310/03_25_2016-002.dat",
            "/raid/nae/pybombs_RFNoC/src/gr-msod_latency/examples/sensor_X310.loc",
            "/raid/nae/pybombs_RFNoC/src/gr-msod_latency/examples/sensor_X310.sys",
            "X310", "NaN", center_freq, ActualBW, meas_interval, 0, samp_rate,
            False)
        self._dest_host_options = (
            "pwct1.ctl.nist.gov",
            "129.6.230.12",
            "129.6.142.181",
            "129.6.142.138",
        )
        self._dest_host_labels = (
            "pwct1",
            "Naceur Laptop",
            "pwct5Desktop",
            "Pwct5",
        )
        self._dest_host_tool_bar = Qt.QToolBar(self)
        self._dest_host_tool_bar.addWidget(Qt.QLabel(dest_host + ": "))
        self._dest_host_combo_box = Qt.QComboBox()
        self._dest_host_tool_bar.addWidget(self._dest_host_combo_box)
        for label in self._dest_host_labels:
            self._dest_host_combo_box.addItem(label)
        self._dest_host_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._dest_host_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._dest_host_options.index(i)))
        self._dest_host_callback(self.dest_host)
        self._dest_host_combo_box.currentIndexChanged.connect(
            lambda i: self.set_dest_host(self._dest_host_options[i]))
        self.top_layout.addWidget(self._dest_host_tool_bar)
        self.blocks_float_to_char_0 = blocks.float_to_char(num_ch, 1.0)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(num_ch)
        self._bandwidth_options = (
            10.08e6,
            9e6,
            4.5e6,
            2.7e6,
            1.08e6,
        )
        self._bandwidth_labels = (
            "10.08e6",
            "9e6",
            "4.5e6",
            "2.7e6",
            "1.08e6",
        )
        self._bandwidth_tool_bar = Qt.QToolBar(self)
        self._bandwidth_tool_bar.addWidget(Qt.QLabel("bandwidth" + ": "))
        self._bandwidth_combo_box = Qt.QComboBox()
        self._bandwidth_tool_bar.addWidget(self._bandwidth_combo_box)
        for label in self._bandwidth_labels:
            self._bandwidth_combo_box.addItem(label)
        self._bandwidth_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._bandwidth_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._bandwidth_options.index(i)))
        self._bandwidth_callback(self.bandwidth)
        self._bandwidth_combo_box.currentIndexChanged.connect(
            lambda i: self.set_bandwidth(self._bandwidth_options[i]))
        self.top_layout.addWidget(self._bandwidth_tool_bar)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.msod_sensor_jsonfile_sink_0, 0))
        self.connect((self.uhd_rfnoc_streamer_logpwr_0, 0),
                     (self.blocks_complex_to_mag_0, 0))
        self.device3.connect(self.uhd_rfnoc_streamer_bin_aggr_0.get_block_id(),
                             0,
                             self.uhd_rfnoc_streamer_logpwr_0.get_block_id(),
                             0)
        self.device3.connect(
            self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0,
            self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0)
        self.device3.connect(self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0,
                             self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0)
        self.device3.connect(self.uhd_rfnoc_streamer_radio_0.get_block_id(), 0,
                             self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0)
        self.device3.connect(
            self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0,
            self.uhd_rfnoc_streamer_bin_aggr_0.get_block_id(), 0)
Example #5
0
    def __init__(self):
        gr.top_block.__init__(self, "Msod Sslsensor N210")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Msod Sslsensor N210")
        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", "MSOD_SSLSensor_N210")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 12.5e6
        self.fft_size = fft_size = 625
        self.num_ch = num_ch = 56
        self.mywindow = mywindow = window.blackmanharris(fft_size)
        self.hz_per_bin = hz_per_bin = samp_rate / fft_size
        self.bandwidth = bandwidth = 10.08e6
        self.window_power = window_power = sum(map(lambda x: x * x, mywindow))
        self.meas_interval = meas_interval = 1e-3
        self.impedance = impedance = 50.0
        self.channel_bw = channel_bw = hz_per_bin * round(
            bandwidth / num_ch / hz_per_bin)
        self.device3 = variable_uhd_device3_0 = ettus.device3(
            uhd.device_addr_t(",".join(('type=x300, addr=usrp02', ""))))
        self.rx_gain = rx_gain = 0
        self.meas_period = meas_period = max(
            1, int(round(meas_interval * samp_rate / fft_size)))
        self.dest_host = dest_host = "129.6.142.103"
        self.center_freq = center_freq = 724e6
        self.Vsq2W_dB = Vsq2W_dB = -10.0 * math.log10(
            fft_size * int(window_power) * impedance)
        self.ActualBW = ActualBW = channel_bw * num_ch

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = (
            12.5e6,
            15.36e6,
            7.68e6,
            3.84e6,
            1.92e6,
        )
        self._samp_rate_labels = (
            '12.5e6',
            '15.36e6',
            '7.68e6',
            '3.84e6',
            '1.92e6',
        )
        self._samp_rate_group_box = Qt.QGroupBox('samp_rate')
        self._samp_rate_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._samp_rate_button_group = variable_chooser_button_group()
        self._samp_rate_group_box.setLayout(self._samp_rate_box)
        for i, label in enumerate(self._samp_rate_labels):
            radio_button = Qt.QRadioButton(label)
            self._samp_rate_box.addWidget(radio_button)
            self._samp_rate_button_group.addButton(radio_button, i)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_button_group.buttonClicked[int].connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_group_box)
        self._rx_gain_range = Range(0, 31.5, 0.5, 0, 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._num_ch_options = (
            56,
            50,
            25,
            15,
            8,
        )
        self._num_ch_labels = (
            '56',
            '50',
            '25',
            '15',
            '8',
        )
        self._num_ch_group_box = Qt.QGroupBox('num_ch')
        self._num_ch_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._num_ch_button_group = variable_chooser_button_group()
        self._num_ch_group_box.setLayout(self._num_ch_box)
        for i, label in enumerate(self._num_ch_labels):
            radio_button = Qt.QRadioButton(label)
            self._num_ch_box.addWidget(radio_button)
            self._num_ch_button_group.addButton(radio_button, i)
        self._num_ch_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._num_ch_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._num_ch_options.index(i)))
        self._num_ch_callback(self.num_ch)
        self._num_ch_button_group.buttonClicked[int].connect(
            lambda i: self.set_num_ch(self._num_ch_options[i]))
        self.top_layout.addWidget(self._num_ch_group_box)
        self._fft_size_options = (
            625,
            1024,
            512,
            256,
            128,
        )
        self._fft_size_labels = (
            '625',
            '1024',
            '512',
            '256',
            '128',
        )
        self._fft_size_tool_bar = Qt.QToolBar(self)
        self._fft_size_tool_bar.addWidget(Qt.QLabel('fft_size' + ": "))
        self._fft_size_combo_box = Qt.QComboBox()
        self._fft_size_tool_bar.addWidget(self._fft_size_combo_box)
        for label in self._fft_size_labels:
            self._fft_size_combo_box.addItem(label)
        self._fft_size_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._fft_size_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._fft_size_options.index(i)))
        self._fft_size_callback(self.fft_size)
        self._fft_size_combo_box.currentIndexChanged.connect(
            lambda i: self.set_fft_size(self._fft_size_options[i]))
        self.top_layout.addWidget(self._fft_size_tool_bar)
        self._center_freq_options = (
            709.01e6,
            782e6,
            724e6,
        )
        self._center_freq_labels = (
            'AT&T',
            'Verizon',
            'ChannelEmulator',
        )
        self._center_freq_tool_bar = Qt.QToolBar(self)
        self._center_freq_tool_bar.addWidget(Qt.QLabel('center_freq' + ": "))
        self._center_freq_combo_box = Qt.QComboBox()
        self._center_freq_tool_bar.addWidget(self._center_freq_combo_box)
        for label in self._center_freq_labels:
            self._center_freq_combo_box.addItem(label)
        self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._center_freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._center_freq_options.index(i)))
        self._center_freq_callback(self.center_freq)
        self._center_freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_center_freq(self._center_freq_options[i]))
        self.top_layout.addWidget(self._center_freq_tool_bar)
        self._bandwidth_options = (
            10.08e6,
            9e6,
            4.5e6,
            2.7e6,
            1.08e6,
        )
        self._bandwidth_labels = (
            '10.08e6',
            '9e6',
            '4.5e6',
            '2.7e6',
            '1.08e6',
        )
        self._bandwidth_tool_bar = Qt.QToolBar(self)
        self._bandwidth_tool_bar.addWidget(Qt.QLabel('bandwidth' + ": "))
        self._bandwidth_combo_box = Qt.QComboBox()
        self._bandwidth_tool_bar.addWidget(self._bandwidth_combo_box)
        for label in self._bandwidth_labels:
            self._bandwidth_combo_box.addItem(label)
        self._bandwidth_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._bandwidth_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._bandwidth_options.index(i)))
        self._bandwidth_callback(self.bandwidth)
        self._bandwidth_combo_box.currentIndexChanged.connect(
            lambda i: self.set_bandwidth(self._bandwidth_options[i]))
        self.top_layout.addWidget(self._bandwidth_tool_bar)
        self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio(
            self.device3,
            uhd.stream_args(  # Tx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="",  # empty
            ),
            uhd.stream_args(  # Rx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args='',
            ),
            1,
            -1)
        self.uhd_rfnoc_streamer_radio_0.set_rate(samp_rate)
        for i in xrange(1):
            self.uhd_rfnoc_streamer_radio_0.set_rx_freq(center_freq, i)
            self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain, i)
            self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("RX2", i)
            self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True, i)
        self.spectrum_latency_jsonfile_sink_0 = spectrum_latency.jsonfile_sink(
            num_ch, "/home/nae/Spectrum-Sensors/N210/Capture.N210/10-25-2016",
            "/raid/nae/gnuradio/src/gr-spectrum_latency/examples/utils/sensor.loc",
            "/raid/nae/gnuradio/src/gr-spectrum_latency/examples/utils/sensor.sys",
            "F37258", "12345", center_freq, bandwidth, meas_interval, 0,
            samp_rate, False)
        self.spectrum_latency_bin_statistics_0 = spectrum_latency.bin_statistics(
            num_ch, meas_period)
        self.spectrum_latency_bin_aggregator_0 = spectrum_latency.bin_aggregator(
            fft_size, num_ch, samp_rate, fft_size, center_freq, ActualBW,
            channel_bw, [0] * fft_size)
        self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (mywindow), True, 1)
        self._dest_host_options = (
            "pwct1.ctl.nist.gov",
            "129.6.142.103",
            "129.6.142.181",
            "pwct5.ctl.nist.gov",
        )
        self._dest_host_labels = (
            'pwct1',
            'NEO_VM',
            'pwct5Desktop',
            'Pwct5',
        )
        self._dest_host_tool_bar = Qt.QToolBar(self)
        self._dest_host_tool_bar.addWidget(Qt.QLabel(dest_host + ": "))
        self._dest_host_combo_box = Qt.QComboBox()
        self._dest_host_tool_bar.addWidget(self._dest_host_combo_box)
        for label in self._dest_host_labels:
            self._dest_host_combo_box.addItem(label)
        self._dest_host_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._dest_host_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._dest_host_options.index(i)))
        self._dest_host_callback(self.dest_host)
        self._dest_host_combo_box.currentIndexChanged.connect(
            lambda i: self.set_dest_host(self._dest_host_options[i]))
        self.top_layout.addWidget(self._dest_host_tool_bar)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(
            gr.sizeof_gr_complex * 1, fft_size)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, num_ch, 30.0 + Vsq2W_dB)
        self.blocks_float_to_char_0 = blocks.float_to_char(num_ch, 1.0)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            fft_size)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.spectrum_latency_bin_aggregator_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.spectrum_latency_jsonfile_sink_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_stream_to_vector_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.spectrum_latency_bin_aggregator_0, 0),
                     (self.spectrum_latency_bin_statistics_0, 0))
        self.connect((self.spectrum_latency_bin_statistics_0, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.uhd_rfnoc_streamer_radio_0, 0),
                     (self.blocks_stream_to_vector_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Msod Sslsensor X310 Rfnoc")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Msod Sslsensor X310 Rfnoc")
        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", "MSOD_SSLSensor_X310_RFNoC")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.fft_size = fft_size = 256
        self.num_ch = num_ch = 50
        self.hz_per_bin = hz_per_bin = samp_rate / fft_size
        self.bandwidth = bandwidth = 9e6
        self.meas_interval = meas_interval = 1e-3
        self.channel_bw = channel_bw = hz_per_bin * round(bandwidth / num_ch / hz_per_bin)
        self.device3 = variable_uhd_device3_0 = ettus.device3(uhd.device_addr_t( ",".join(("type=x300", "addr=usrp0")) ))
        self.rx_gain = rx_gain = 0
        self.meas_period = meas_period = max(1, int(round(meas_interval * samp_rate / fft_size)))
        self.impedance = impedance = 50.0
        self.dest_host = dest_host = "129.6.142.138"
        self.center_freq = center_freq = 724e6
        self.ActualBW = ActualBW = channel_bw * num_ch

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = (10e6, 25e6, 12.5e6, 3.84e6, 5e5, )
        self._samp_rate_labels = ("10e6", "25e6", "12.5e6", "3.84e6", "5e5", )
        self._samp_rate_group_box = Qt.QGroupBox("samp_rate")
        self._samp_rate_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._samp_rate_button_group = variable_chooser_button_group()
        self._samp_rate_group_box.setLayout(self._samp_rate_box)
        for i, label in enumerate(self._samp_rate_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._samp_rate_box.addWidget(radio_button)
        	self._samp_rate_button_group.addButton(radio_button, i)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_button_group.buttonClicked[int].connect(
        	lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_group_box)
        self._rx_gain_range = Range(0, 31.5, 0.5, 0, 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._num_ch_options = (56, 50, 25, 15, 8, )
        self._num_ch_labels = ("56", "50", "25", "15", "8", )
        self._num_ch_group_box = Qt.QGroupBox("num_ch")
        self._num_ch_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._num_ch_button_group = variable_chooser_button_group()
        self._num_ch_group_box.setLayout(self._num_ch_box)
        for i, label in enumerate(self._num_ch_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._num_ch_box.addWidget(radio_button)
        	self._num_ch_button_group.addButton(radio_button, i)
        self._num_ch_callback = lambda i: Qt.QMetaObject.invokeMethod(self._num_ch_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._num_ch_options.index(i)))
        self._num_ch_callback(self.num_ch)
        self._num_ch_button_group.buttonClicked[int].connect(
        	lambda i: self.set_num_ch(self._num_ch_options[i]))
        self.top_layout.addWidget(self._num_ch_group_box)
        self._fft_size_options = (2048, 1024, 512, 256, 128, )
        self._fft_size_labels = ("2048", "1024", "512", "256", "128", )
        self._fft_size_tool_bar = Qt.QToolBar(self)
        self._fft_size_tool_bar.addWidget(Qt.QLabel("fft_size"+": "))
        self._fft_size_combo_box = Qt.QComboBox()
        self._fft_size_tool_bar.addWidget(self._fft_size_combo_box)
        for label in self._fft_size_labels: self._fft_size_combo_box.addItem(label)
        self._fft_size_callback = lambda i: Qt.QMetaObject.invokeMethod(self._fft_size_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._fft_size_options.index(i)))
        self._fft_size_callback(self.fft_size)
        self._fft_size_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_fft_size(self._fft_size_options[i]))
        self.top_layout.addWidget(self._fft_size_tool_bar)
        self._center_freq_options = (709.01e6, 782e6, 724e6, )
        self._center_freq_labels = ("AT&T", "Verizon", "ChannelEmulator", )
        self._center_freq_tool_bar = Qt.QToolBar(self)
        self._center_freq_tool_bar.addWidget(Qt.QLabel("center_freq"+": "))
        self._center_freq_combo_box = Qt.QComboBox()
        self._center_freq_tool_bar.addWidget(self._center_freq_combo_box)
        for label in self._center_freq_labels: self._center_freq_combo_box.addItem(label)
        self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._center_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._center_freq_options.index(i)))
        self._center_freq_callback(self.center_freq)
        self._center_freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_center_freq(self._center_freq_options[i]))
        self.top_layout.addWidget(self._center_freq_tool_bar)
        self.uhd_rfnoc_streamer_vector_iir_0 = ettus.rfnoc_generic(
              self.device3,
              uhd.stream_args( # TX Stream Args
                  cpu_format="fc32",
                  otw_format="sc16",
                  args="spp={},alpha={},beta={}".format(fft_size, 0.984375, 0.015625),
              ),
              uhd.stream_args( # TX Stream Args
                  cpu_format="fc32",
                  otw_format="sc16",
                  args="spp={},alpha={},beta={}".format(fft_size, 0.984375, 0.015625),
              ),
              "VectorIIR", -1, -1,
        )
        self.uhd_rfnoc_streamer_vector_iir_0.set_arg("alpha", 0.984375)
        self.uhd_rfnoc_streamer_vector_iir_0.set_arg("beta",  0.015625)
          
        self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio(
            self.device3,
            uhd.stream_args( # Tx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="", # empty
            ),
            uhd.stream_args( # Rx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
        	args="spp=256",
            ),
            0, -1
        )
        self.uhd_rfnoc_streamer_radio_0.set_rx_freq(center_freq)
        self.uhd_rfnoc_streamer_radio_0.set_rx_rate(samp_rate)
        self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain)
        self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("TX/RX")
        self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True)
        self.uhd_rfnoc_streamer_logpwr_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args( # TX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(num_ch, "" if num_ch == 1 else "spp={0}".format(num_ch)),
            ),
            uhd.stream_args( # RX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(num_ch, "" if num_ch == 1 else "spp={0}".format(num_ch)),
            ),
            "LogPwr", -1, -1,
        )
        self.uhd_rfnoc_streamer_fifo_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args( # TX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(fft_size, "" if fft_size == 1 else "spp={0}".format(fft_size)),
            ),
            uhd.stream_args( # RX Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="gr_vlen={0},{1}".format(fft_size, "" if fft_size == 1 else "spp={0}".format(fft_size)),
            ),
            "FIFO", -1, -1,
        )
        self.uhd_rfnoc_streamer_fft_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args( # TX Stream Args
                cpu_format="fc32", # TODO: This must be made an option
                otw_format="sc16",
                args="spp={},magnitude_out={}".format(256, "COMPLEX"),
            ),
            uhd.stream_args( # RX Stream Args
                cpu_format="fc32", # TODO: This must be made an option
                otw_format="sc16",
                args="",
            ),
            "FFT", -1, -1,
        )
        self.uhd_rfnoc_streamer_bin_aggr_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(
                cpu_format="fc32", # TODO: This must be made an option
                otw_format="sc16",
                args=""
            ),
            uhd.stream_args(
                cpu_format="fc32", # TODO: This must be made an option
                otw_format="sc16",
                args="",
            ),
            "BinAggr", -1, -1,
        )
        self.msod_sensor_jsonfile_sink_0 = msod_sensor.jsonfile_sink(num_ch, "/home/nae/capture/capture_X310/03_25_2016-002.dat", "/raid/nae/pybombs_RFNoC/src/gr-msod_latency/examples/sensor_X310.loc", "/raid/nae/pybombs_RFNoC/src/gr-msod_latency/examples/sensor_X310.sys", "X310", "NaN", center_freq, ActualBW, meas_interval, 0, samp_rate, False)
        self._dest_host_options = ("pwct1.ctl.nist.gov", "129.6.230.12", "129.6.142.181", "129.6.142.138", )
        self._dest_host_labels = ("pwct1", "Naceur Laptop", "pwct5Desktop", "Pwct5", )
        self._dest_host_tool_bar = Qt.QToolBar(self)
        self._dest_host_tool_bar.addWidget(Qt.QLabel(dest_host+": "))
        self._dest_host_combo_box = Qt.QComboBox()
        self._dest_host_tool_bar.addWidget(self._dest_host_combo_box)
        for label in self._dest_host_labels: self._dest_host_combo_box.addItem(label)
        self._dest_host_callback = lambda i: Qt.QMetaObject.invokeMethod(self._dest_host_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._dest_host_options.index(i)))
        self._dest_host_callback(self.dest_host)
        self._dest_host_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_dest_host(self._dest_host_options[i]))
        self.top_layout.addWidget(self._dest_host_tool_bar)
        self.blocks_float_to_char_0 = blocks.float_to_char(num_ch, 1.0)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(num_ch)
        self._bandwidth_options = (10.08e6, 9e6, 4.5e6, 2.7e6, 1.08e6, )
        self._bandwidth_labels = ("10.08e6", "9e6", "4.5e6", "2.7e6", "1.08e6", )
        self._bandwidth_tool_bar = Qt.QToolBar(self)
        self._bandwidth_tool_bar.addWidget(Qt.QLabel("bandwidth"+": "))
        self._bandwidth_combo_box = Qt.QComboBox()
        self._bandwidth_tool_bar.addWidget(self._bandwidth_combo_box)
        for label in self._bandwidth_labels: self._bandwidth_combo_box.addItem(label)
        self._bandwidth_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bandwidth_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._bandwidth_options.index(i)))
        self._bandwidth_callback(self.bandwidth)
        self._bandwidth_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_bandwidth(self._bandwidth_options[i]))
        self.top_layout.addWidget(self._bandwidth_tool_bar)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_char_0, 0))    
        self.connect((self.blocks_float_to_char_0, 0), (self.msod_sensor_jsonfile_sink_0, 0))    
        self.connect((self.uhd_rfnoc_streamer_logpwr_0, 0), (self.blocks_complex_to_mag_0, 0))    
        self.device3.connect(self.uhd_rfnoc_streamer_bin_aggr_0.get_block_id(), 0, self.uhd_rfnoc_streamer_logpwr_0.get_block_id(), 0)    
        self.device3.connect(self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0, self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0)    
        self.device3.connect(self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0)    
        self.device3.connect(self.uhd_rfnoc_streamer_radio_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0)    
        self.device3.connect(self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0, self.uhd_rfnoc_streamer_bin_aggr_0.get_block_id(), 0)    
Example #7
0
    def __init__(self):
        gr.top_block.__init__(self, "rfnoc_rx_e3")

        ##################################################
        # Variables
        ##################################################
        self.vec_length = vec_length = 1
        self.device3 = variable_uhd_device3_0 = ettus.device3(
            uhd.device_addr_t(",".join(('type=e3x0', ""))))
        self.server_port = server_port = 30000
        self.server_address = server_address = "192.168.10.184"
        self.samp_rate = samp_rate = 1e6
        self.rx_gain_A2 = rx_gain_A2 = 60
        self.rf_freq = rf_freq = 871e6
        self.decim_rate = decim_rate = 500e3

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_push_sink_1 = zeromq.push_sink(gr.sizeof_gr_complex,
                                                   vec_length, 'tcp://*:9998',
                                                   100, False, -1)
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            (str(server_address), int(server_port)), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio(
            self.device3,
            uhd.stream_args(  # Tx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args="",  # empty
            ),
            uhd.stream_args(  # Rx Stream Args
                cpu_format="fc32",
                otw_format="sc16",
                args='',
            ),
            0,
            -1)
        self.uhd_rfnoc_streamer_radio_0.set_rate(samp_rate)

        self.uhd_rfnoc_streamer_radio_0.set_rx_freq(rf_freq, 0)
        self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain_A2, 0)
        self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True, 0)

        self.uhd_rfnoc_streamer_radio_0.set_rx_bandwidth(samp_rate, 0)

        if "RX2":
            self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("RX2", 0)

        self.uhd_rfnoc_streamer_radio_0.set_clock_source("internal")
        self.uhd_rfnoc_streamer_ddc_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(  # TX Stream Args
                cpu_format="fc32",  # TODO: This must be made an option
                otw_format="sc16",
                channels=range(1),
                args=
                "input_rate={},output_rate={},fullscale={},freq={},gr_vlen={},{}"
                .format(
                    samp_rate, samp_rate, 1.0, 0, vec_length,
                    "" if vec_length == 1 else "spp={}".format(vec_length)),
            ),
            uhd.stream_args(  # RX Stream Args
                cpu_format="fc32",  # TODO: This must be made an option
                otw_format="sc16",
                channels=range(1),
                args="gr_vlen={},{}".format(
                    vec_length,
                    "" if vec_length == 1 else "spp={}".format(vec_length)),
            ),
            "DDC",
            -1,
            -1,
        )
        for chan in xrange(1):
            self.uhd_rfnoc_streamer_ddc_0.set_arg("input_rate",
                                                  float(samp_rate), chan)
            self.uhd_rfnoc_streamer_ddc_0.set_arg("output_rate",
                                                  float(samp_rate), chan)
            self.uhd_rfnoc_streamer_ddc_0.set_arg("fullscale", 1.0, chan)
            self.uhd_rfnoc_streamer_ddc_0.set_arg("freq", 0, chan)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.uhd_rfnoc_streamer_ddc_0, 0),
                     (self.zeromq_push_sink_1, 0))
        self.device3.connect(self.uhd_rfnoc_streamer_radio_0.get_block_id(), 0,
                             self.uhd_rfnoc_streamer_ddc_0.get_block_id(), 0)
Example #8
0
    def __init__(self):
        gr.top_block.__init__(self, "Latencytest")

        ##################################################
        # Variables
        ##################################################
        self.spp = spp = 4
        self.vlb = vlb = spp * 4
        self.device3 = variable_uhd_device3_0 = ettus.device3(
            uhd.device_addr_t(",".join(('type=x300', 'args'))))
        self.samp_rate = samp_rate = 500000

        ##################################################
        # Blocks
        ##################################################
        self.uhd_rfnoc_streamer_fifo_0 = ettus.rfnoc_generic(
            self.device3,
            uhd.stream_args(  # TX Stream Args
                cpu_format="u8",
                otw_format="u8",
                args="gr_vlen={0},{1}".format(
                    vlb, "" if vlb == 1 else "spp={0}".format(vlb)),
            ),
            uhd.stream_args(  # RX Stream Args
                cpu_format="u8",
                otw_format="u8",
                args="gr_vlen={0},{1}".format(
                    vlb, "" if vlb == 1 else "spp={0}".format(vlb)),
            ),
            "FIFO",
            -1,
            -1,
        )
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_int * spp,
                                                   samp_rate, True)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_int * spp,
            '/home/vivado/rfnoc/src/rfnoc-Kwan/test_in.bin', False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_int * spp, '/home/vivado/rfnoc/src/rfnoc-Kwan/out.bin',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_copy_0 = blocks.copy(gr.sizeof_int * spp)
        self.blocks_copy_0.set_enabled(True)
        self.Kwan_latencytest_0 = Kwan.latencytest(
            self.device3,
            uhd.stream_args(  # TX Stream Args
                cpu_format="u8",
                otw_format="u8",
                args="gr_vlen={0},{1}".format(
                    vlb, "" if vlb == 1 else "spp={0}".format(vlb)),
            ),
            uhd.stream_args(  # RX Stream Args
                cpu_format="u8",
                otw_format="u8",
                args="gr_vlen={0},{1}".format(
                    vlb, "" if vlb == 1 else "spp={0}".format(vlb)),
            ),
            -1,
            -1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_copy_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.uhd_rfnoc_streamer_fifo_0, 0))
        self.connect((self.Kwan_latencytest_0, 0), (self.blocks_copy_0, 0))
        self.device3.connect(self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0,
                             self.Kwan_latencytest_0.get_block_id(), 0)