Ejemplo n.º 1
0
    def __init__(self):
        gr.top_block.__init__(self, "CogMAC_plus")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("CogMAC_plus")
        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", "CogMAC_plus")
        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.usrp_device_address = usrp_device_address = "addr=10.0.0.6"
        self.tx_center_frequency = tx_center_frequency = 3.9e8
        self.system_time_granularity_us = system_time_granularity_us = 10
        self.source_address = source_address = 1
        self.samp_rate = samp_rate = 400000
        self.rx_gain = rx_gain = range_rx_gain
        self.rx_center_frequency = rx_center_frequency = 3.9e8

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

        self.mu = mu = range_mu
        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.destination_address = destination_address = 3
        self.cs_threshold = cs_threshold = 0.005

        ##################################################
        # Blocks
        ##################################################
        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_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.inets_sending_0 = inets.sending(develop_mode=0, block_id=11, constellation=gnuradio.digital.constellation_qpsk().base(), preamble=diff_preamble_128, samp_rate=samp_rate, sps=sps, system_time_granularity_us=system_time_granularity_us, usrp_device_address=usrp_device_address, center_frequency=tx_center_frequency, interframe_interval_s=0.005, t_pretx_interval_s=0, file_name_extension_t_control="t1TXs", file_name_extension_pending="Tfr", record_on=0, name_with_timestamp=1, tx_gain=0)
        self.inets_run_0 = inets.run(5, 10)
        self.inets_receiving_0 = inets.receiving(1, 21, gnuradio.digital.constellation_qpsk().base(), rrc, mu, diff_preamble_128, rx_gain, samp_rate, sps, 30, usrp_device_address, rx_center_frequency)
        self.inets_general_timer_1 = inets.general_timer(0, 3, 0, 100, 10, 0)
        self.inets_general_timer_0 = inets.general_timer(1, 15, 0, 1000, 10, 0)
        self.inets_framing_0 = inets.framing(0, 17, 1, 1, 10, 1, destination_address, 1, source_address, 1, 318, 2, 524, 2, 2, -1, 1, 0, ([2, 3]), ([1000, 1000]), 2, 0, 300, 1)
        self.inets_frame_replicate_0 = inets.frame_replicate(0, 37, 4)
        self.inets_frame_probe_0_0 = inets.frame_probe(0, 100, 0, 0, 0.01, 0, "/home/inets/source/gr-inets/results/", "", 1)
        self.inets_frame_probe_0 = inets.frame_probe(2, 100, 0, 1, 0.01, 0, "/home/inets/source/gr-inets/results/", "", 1)
        self.inets_frame_path_0_0_2 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_1_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_1 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0_2_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0_2 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0 = inets.frame_path(0, 39)
        self.inets_frame_index_selector_1 = inets.frame_index_selector(0, 33, (1, ), 0)
        self.inets_frame_index_selector_0 = inets.frame_index_selector(0, 33, (10, ), 0)
        self.inets_frame_counter_0 = inets.frame_counter(0, 36, 4)
        self.inets_frame_check_0 = inets.frame_check(0, 9)
        self.inets_frame_buffer_0_0 = inets.frame_buffer(0, 16, 100, 0, 0, 0)
        self.inets_frame_buffer_0 = inets.frame_buffer(0, 16, 10, 0, 0, 1)
        self.inets_frame_and_0 = inets.frame_and(0, 38, 0)
        self.inets_frame_analysis_0 = inets.frame_analysis(0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address)
        self.inets_dummy_source_0 = inets.dummy_source(0, 23, 300, 3, 100)
        self.inets_cogmac_ch_pool_0 = inets.cogmac_ch_pool(1, 35, 3, 390000000, 0, 10000000)
        self.inets_carrier_sensing_0 = inets.carrier_sensing(1, 11, 2, 1000, 0.005, 1000, 100)
        self.inets_backoff_0 = inets.backoff(0, 11, 3, 10, 1000, 4000, 1, 0.005, 10, 1)
        self.inets_address_check_0 = inets.address_check(0, 17, source_address)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.inets_backoff_0, 'frame_info_out'), (self.inets_frame_buffer_0, 'indicate_empty'))
        self.msg_connect((self.inets_carrier_sensing_0, 'frame_info_pass_out'), (self.inets_frame_path_0_0_1_0, 'frame_in'))
        self.msg_connect((self.inets_carrier_sensing_0, 'frame_info_fail_out'), (self.inets_frame_path_0_0_1_0_2, 'frame_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'next_frequency_out'), (self.inets_frame_path_0_0_1_0_0, 'frame_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'next_frequency_out'), (self.inets_sending_0, 'reconfig_in'))
        self.msg_connect((self.inets_dummy_source_0, 'output'), (self.inets_framing_0, 'data_in'))
        self.msg_connect((self.inets_frame_analysis_0, 'frame_info_out'), (self.inets_frame_check_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_and_0, 'frame_out'), (self.inets_frame_counter_0, 'reset_in'))
        self.msg_connect((self.inets_frame_and_0, 'frame_out'), (self.inets_frame_path_0_0_1_1_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'dequeue_element'), (self.inets_frame_index_selector_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'buffer_not_full'), (self.inets_frame_path_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'buffer_empty'), (self.inets_frame_path_0_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'buffer_empty'), (self.inets_frame_path_0_0_1_0_2_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'dequeue_element'), (self.inets_general_timer_0, 'suspend_timer_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'dequeue_element'), (self.inets_sending_0, 'in'))
        self.msg_connect((self.inets_frame_check_0, 'good_frame_info_out'), (self.inets_address_check_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_check_0, 'good_frame_info_out'), (self.inets_general_timer_1, 'active_in'))
        self.msg_connect((self.inets_frame_counter_0, 'select_out'), (self.inets_carrier_sensing_0, 'info_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'unselected_frame_out'), (self.inets_frame_index_selector_1, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'frame_out'), (self.inets_frame_path_0, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'unselected_frame_out'), (self.inets_frame_path_0, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'frame_out'), (self.inets_frame_replicate_0, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_1, 'frame_out'), (self.inets_frame_buffer_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_index_selector_1, 'frame_out'), (self.inets_frame_path_0_0_1_1, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_1, 'unselected_frame_out'), (self.inets_frame_path_0_0_1_1, 'frame_in'))
        self.msg_connect((self.inets_frame_path_0, 'frame_out'), (self.inets_frame_buffer_0, 'dequeue'))
        self.msg_connect((self.inets_frame_path_0_0, 'frame_out'), (self.inets_dummy_source_0, 'trigger'))
        self.msg_connect((self.inets_frame_path_0_0_0, 'frame_out'), (self.inets_framing_0, 'reset_index'))
        self.msg_connect((self.inets_frame_path_0_0_1_0, 'frame_out'), (self.inets_frame_buffer_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_path_0_0_1_0, 'frame_out'), (self.inets_general_timer_0, 'suspend_timer_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_0, 'frame_out'), (self.inets_receiving_0, 'reconfig_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_0_0, 'frame_out'), (self.inets_general_timer_0, 'active_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_2, 'frame_out'), (self.inets_frame_buffer_0_0, 'flush'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_2, 'frame_out'), (self.inets_general_timer_0, 'suspend_timer_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_2_0, 'frame_out'), (self.inets_frame_and_0, 'frame_II_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_1, 'frame_out'), (self.inets_frame_buffer_0_0, 'enqueue'))
        self.msg_connect((self.inets_frame_path_0_0_1_1_0, 'frame_out'), (self.inets_backoff_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_1_0, 'frame_out'), (self.inets_general_timer_0, 'resume_timer_in'))
        self.msg_connect((self.inets_frame_path_0_0_2, 'frame_out'), (self.inets_frame_buffer_0, 'dequeue'))
        self.msg_connect((self.inets_frame_replicate_0, 'replicate_out'), (self.inets_frame_path_0_0_1_1, 'frame_in'))
        self.msg_connect((self.inets_framing_0, 'frame_out'), (self.inets_frame_buffer_0, 'enqueue'))
        self.msg_connect((self.inets_general_timer_0, 'expire_signal_out'), (self.inets_cogmac_ch_pool_0, 'change_in'))
        self.msg_connect((self.inets_general_timer_0, 'expire_signal_out'), (self.inets_frame_path_0_0_1_0_0_0, 'frame_in'))
        self.msg_connect((self.inets_general_timer_1, 'expire_signal_out'), (self.inets_general_timer_0, 'resume_timer_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_power_out'), (self.inets_carrier_sensing_0, 'power_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_frame_out'), (self.inets_frame_analysis_0, 'frame_in'))
        self.msg_connect((self.inets_run_0, 'trigger_out'), (self.inets_frame_buffer_0, 'indicate_empty'))
        self.msg_connect((self.inets_run_0, 'trigger_out'), (self.inets_general_timer_0, 'active_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'), (self.inets_frame_and_0, 'frame_I_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'), (self.inets_frame_counter_0, 'counts_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'), (self.inets_frame_path_0_0_1_0, 'frame_in'))
Ejemplo n.º 2
0
    def __init__(self,
                 constellation=gnuradio.digital.constellation_qpsk().base()):
        gr.top_block.__init__(self, "CogMAC")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("CogMAC")
        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", "CogMAC")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.constellation = constellation

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 0
        self.range_mu = range_mu = 0.6
        self.usrp_device_address = usrp_device_address = "addr=10.0.0.20"
        self.tx_mode_ms = tx_mode_ms = 5
        self.system_time_granularity_us = system_time_granularity_us = 1000
        self.source_address = source_address = 3
        self.samp_rate = samp_rate = 400000
        self.rx_mode_ms = rx_mode_ms = 5
        self.rx_gain = rx_gain = range_rx_gain

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

        self.padding = padding = 64
        self.mu = mu = range_mu
        self.inter_fr_ms = inter_fr_ms = 5
        self.frame_length = frame_length = 837
        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.destination_address = destination_address = 1
        self.cs_threshold = cs_threshold = 0.005
        self.ch_switch_ms = ch_switch_ms = 5
        self.ch_pool_size = ch_pool_size = 10
        self.center_frequency = center_frequency = 400000000
        self.PU_time_ms = PU_time_ms = 100
        self.N_Mul_Fr = N_Mul_Fr = 10
        self.CCA2_ms = CCA2_ms = 10

        ##################################################
        # Blocks
        ##################################################
        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_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.inets_unbundle_0_0_0_0_0 = inets.unbundle(0, 16, 'N_Mul_Fr')
        self.inets_unbundle_0_0_0_0 = inets.unbundle(0, 16, 'N_Fr')
        self.inets_unbundle_0_0_0 = inets.unbundle(0, 16, 'CCA1_ms')
        self.inets_unbundle_0_0 = inets.unbundle(0, 16, 'N_PU')
        self.inets_unbundle_0 = inets.unbundle(0, 16, 'N_Re_fr')
        self.inets_sending_0 = inets.sending(
            develop_mode=0,
            block_id=11,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
            usrp_device_address=usrp_device_address,
            center_frequency=center_frequency,
            interframe_interval_s=0.005,
            t_pretx_interval_s=0,
            file_name_extension_t_control="t1TXs",
            file_name_extension_pending="Tfr",
            record_on=0,
            name_with_timestamp=1,
            tx_gain=5)
        self.inets_run_0 = inets.run(1, 10)
        self.inets_receiving_0 = inets.receiving(
            0, 21,
            gnuradio.digital.constellation_qpsk().base(), rrc, mu,
            diff_preamble_128, rx_gain, samp_rate, sps, 30,
            usrp_device_address, center_frequency)
        self.inets_general_timer_3 = inets.general_timer(
            0, 3, 0, CCA2_ms, 10, 0)
        self.inets_general_timer_2_0 = inets.general_timer(0, 3, 0, 100, 10, 0)
        self.inets_general_timer_2 = inets.general_timer(0, 3, 0, 200, 10, 0)
        self.inets_general_timer_1_0 = inets.general_timer(
            0, 3, 0, ch_switch_ms, 10, 0)
        self.inets_general_timer_1 = inets.general_timer(
            0, 3, 0, ch_switch_ms, 10, 0)
        self.inets_general_timer_0 = inets.general_timer(
            0, 3, 0, 100000, 10, 0)
        self.inets_framing_0 = inets.framing(0, 17, 1, 1, 10, 1,
                                             destination_address, 1,
                                             source_address, 1, 318, 2, 524, 2,
                                             2, -1, 1, 0, ([2, 3]),
                                             ([1000, 1000]), 2, 0, 300, 1)
        self.inets_frame_replicate_0 = inets.frame_replicate(1, 39, 4)
        self.inets_frame_probe_0_1 = inets.frame_probe(
            1, 99, 0, 0, 0.001, 0, "/home/inets/source/gr-inets/results/", "",
            1)
        self.inets_frame_probe_0_0 = inets.frame_probe(
            1, 101, 0, 0, 0.01, 0, "/home/inets/source/gr-inets/results/", "",
            1)
        self.inets_frame_probe_0 = inets.frame_probe(
            1, 100, 0, 0, 0.001, 0, "/home/inets/source/gr-inets/results/", "",
            1)
        self.inets_frame_path_2_0 = inets.frame_path(0, 39)
        self.inets_frame_path_2 = inets.frame_path(0, 39)
        self.inets_frame_path_1_1_0_0_1 = inets.frame_path(0, 39)
        self.inets_frame_path_1_1_0_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1_1_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1_1 = inets.frame_path(0, 39)
        self.inets_frame_path_1_0_0_1_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1_0_0_1 = inets.frame_path(0, 39)
        self.inets_frame_path_1_0_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1 = inets.frame_path(0, 39)
        self.inets_frame_path_0 = inets.frame_path(0, 39)
        self.inets_frame_index_selector_0_1 = inets.frame_index_selector(
            0, 33, (1, ), 1)
        self.inets_frame_index_selector_0_0_0 = inets.frame_index_selector(
            0, 33, (10, ), 0)
        self.inets_frame_index_selector_0_0 = inets.frame_index_selector(
            0, 33, (1, ), 0)
        self.inets_frame_index_selector_0 = inets.frame_index_selector(
            0, 33, (10, ), 0)
        self.inets_frame_counter_1 = inets.frame_counter(0, 36, 4, 0)
        self.inets_frame_counter_0 = inets.frame_counter(
            1, 36, ch_pool_size, 0)
        self.inets_frame_check_0 = inets.frame_check(0, 9)
        self.inets_frame_buffer_0_0_0 = inets.frame_buffer(0, 16, 20, 1, 1, 0)
        self.inets_frame_buffer_0_0 = inets.frame_buffer(0, 16, 13, 0, 0, 0)
        self.inets_frame_buffer_0 = inets.frame_buffer(0, 15, 10, 0, 0, 1)
        self.inets_frame_and_0_0 = inets.frame_and(0, 38, 0)
        self.inets_frame_analysis_0 = inets.frame_analysis(
            0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address)
        self.inets_dummy_source_0 = inets.dummy_source(0, 23, frame_length, 3,
                                                       1)
        self.inets_cogmac_timing_0 = inets.cogmac_timing(
            1, 37, frame_length,
            constellation.bits_per_symbol() * (samp_rate / sps), samp_rate,
            (diff_preamble_128), 64, CCA2_ms, PU_time_ms, tx_mode_ms,
            rx_mode_ms, 15, 148, inter_fr_ms, ch_pool_size, ch_switch_ms,
            N_Mul_Fr)
        self.inets_cogmac_rm_rep_0 = inets.cogmac_rm_rep(0, 37)
        self.inets_cogmac_ch_pool_0 = inets.cogmac_ch_pool(
            0, 35, ch_pool_size, 410000000, 0, 10000000)
        self.inets_carrier_sensing_0_1 = inets.carrier_sensing(
            0, 11, 2, 500, cs_threshold, system_time_granularity_us, 100, 15)
        self.inets_carrier_sensing_0_0 = inets.carrier_sensing(
            0, 13, 2, CCA2_ms, cs_threshold, system_time_granularity_us, 100,
            15)
        self.inets_carrier_sensing_0 = inets.carrier_sensing(
            0, 11, 2, 60, cs_threshold, system_time_granularity_us, 100, 15)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.inets_carrier_sensing_0, 'cmd_pass_out'),
                         (self.inets_frame_counter_0, 'counts_in'))
        self.msg_connect((self.inets_carrier_sensing_0, 'cmd_fail_out'),
                         (self.inets_general_timer_2_0, 'active_in'))
        self.msg_connect((self.inets_carrier_sensing_0_0, 'cmd_fail_out'),
                         (self.inets_frame_path_1_0_0_0, 'frame_in'))
        self.msg_connect((self.inets_carrier_sensing_0_0, 'cmd_pass_out'),
                         (self.inets_frame_path_1_0_0_1_0, 'frame_in'))
        self.msg_connect((self.inets_carrier_sensing_0_0, 'cmd_fail_out'),
                         (self.inets_general_timer_2_0, 'active_in'))
        self.msg_connect((self.inets_carrier_sensing_0_1, 'cmd_pass_out'),
                         (self.inets_frame_and_0_0, 'frame_I_in'))
        self.msg_connect((self.inets_carrier_sensing_0_1, 'cmd_fail_out'),
                         (self.inets_general_timer_2_0, 'active_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'CCA_CH_f_out'),
                         (self.inets_frame_path_1_0_0_1, 'frame_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'CCA_one_f_out'),
                         (self.inets_frame_path_1_0_0_1, 'frame_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'CCA_CH_f_out'),
                         (self.inets_general_timer_1, 'active_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'CCA_one_f_out'),
                         (self.inets_general_timer_1_0, 'active_in'))
        self.msg_connect((self.inets_cogmac_rm_rep_0, 'new_cmd_out'),
                         (self.inets_frame_probe_0_1, 'info_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cmd_out'),
                         (self.inets_cogmac_ch_pool_0, 'CCA_CH_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cmd_out'),
                         (self.inets_dummy_source_0, 'trigger'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cmd_out'),
                         (self.inets_general_timer_0, 'active_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0, 'cmd_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0_0, 'cmd_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0_0_0, 'cmd_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0_0_0_0, 'cmd_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0_0_0_0_0, 'cmd_in'))
        self.msg_connect((self.inets_dummy_source_0, 'output'),
                         (self.inets_framing_0, 'data_in'))
        self.msg_connect((self.inets_frame_analysis_0, 'frame_info_out'),
                         (self.inets_frame_check_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_and_0_0, 'frame_out'),
                         (self.inets_frame_buffer_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_and_0_0, 'frame_out'),
                         (self.inets_framing_0, 'reset_index'))
        self.msg_connect((self.inets_frame_buffer_0, 'dequeue_element'),
                         (self.inets_frame_index_selector_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'dequeue_element'),
                         (self.inets_frame_index_selector_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'buffer_not_full'),
                         (self.inets_frame_path_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'buffer_full'),
                         (self.inets_frame_and_0_0, 'frame_II_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'dequeue_element'),
                         (self.inets_frame_buffer_0_0_0, 'enqueue'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'dequeue_element'),
                         (self.inets_frame_path_1_1, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0_0_0, 'dequeue_element'),
                         (self.inets_frame_counter_1, 'counts_in'))
        self.msg_connect((self.inets_frame_check_0, 'good_frame_info_out'),
                         (self.inets_cogmac_rm_rep_0, 'frame_cmd_in'))
        self.msg_connect((self.inets_frame_check_0, 'good_frame_info_out'),
                         (self.inets_general_timer_2_0, 'active_in'))
        self.msg_connect((self.inets_frame_counter_0, 'unselect_out'),
                         (self.inets_frame_path_1_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_0, 'select_out'),
                         (self.inets_frame_path_1_1_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_0, 'select_out'),
                         (self.inets_frame_path_1_1_0_0_1, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_1, 'unselect_out'),
                         (self.inets_frame_path_1_0_0_1_0, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_1, 'select_out'),
                         (self.inets_frame_path_1_1_0_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_1, 'select_out'),
                         (self.inets_general_timer_3, 'active_in'))
        self.msg_connect(
            (self.inets_frame_index_selector_0, 'unselected_frame_out'),
            (self.inets_frame_path_1, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'frame_out'),
                         (self.inets_frame_replicate_0, 'frame_in'))
        self.msg_connect(
            (self.inets_frame_index_selector_0_0, 'unselected_frame_out'),
            (self.inets_frame_index_selector_0_0_0, 'frame_in'))
        self.msg_connect(
            (self.inets_frame_index_selector_0_0_0, 'unselected_frame_out'),
            (self.inets_frame_buffer_0, 'dequeue'))
        self.msg_connect((self.inets_frame_index_selector_0_1, 'frame_out'),
                         (self.inets_general_timer_2, 'active_in'))
        self.msg_connect((self.inets_frame_path_0, 'frame_out'),
                         (self.inets_dummy_source_0, 'trigger'))
        self.msg_connect((self.inets_frame_path_1, 'frame_out'),
                         (self.inets_frame_buffer_0_0, 'enqueue'))
        self.msg_connect((self.inets_frame_path_1_0_0, 'frame_out'),
                         (self.inets_cogmac_ch_pool_0, 'CCA_CH_in'))
        self.msg_connect((self.inets_frame_path_1_0_0_0, 'frame_out'),
                         (self.inets_frame_buffer_0_0_0, 'flush'))
        self.msg_connect((self.inets_frame_path_1_0_0_1, 'frame_out'),
                         (self.inets_receiving_0, 'reconfig_in'))
        self.msg_connect((self.inets_frame_path_1_0_0_1, 'frame_out'),
                         (self.inets_sending_0, 'reconfig_in'))
        self.msg_connect((self.inets_frame_path_1_0_0_1_0, 'frame_out'),
                         (self.inets_receiving_0, 'rx_switch_in'))
        self.msg_connect((self.inets_frame_path_1_1, 'frame_out'),
                         (self.inets_frame_buffer_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_path_1_1_0_0, 'frame_out'),
                         (self.inets_frame_counter_0, 'reset_in'))
        self.msg_connect((self.inets_frame_path_1_1_0_0_0, 'frame_out'),
                         (self.inets_frame_counter_1, 'reset_in'))
        self.msg_connect((self.inets_frame_path_1_1_0_0_1, 'frame_out'),
                         (self.inets_cogmac_ch_pool_0, 'CCA_one_in'))
        self.msg_connect((self.inets_frame_path_2, 'frame_out'),
                         (self.inets_frame_buffer_0_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_path_2_0, 'frame_out'),
                         (self.inets_frame_counter_1, 'reset_in'))
        self.msg_connect((self.inets_frame_replicate_0, 'complete_out'),
                         (self.inets_frame_buffer_0, 'dequeue'))
        self.msg_connect((self.inets_frame_replicate_0, 'replicate_out'),
                         (self.inets_frame_path_1, 'frame_in'))
        self.msg_connect((self.inets_framing_0, 'frame_out'),
                         (self.inets_frame_buffer_0, 'enqueue'))
        self.msg_connect((self.inets_general_timer_0, 'expire_signal_out'),
                         (self.inets_dummy_source_0, 'stop_in'))
        self.msg_connect((self.inets_general_timer_1, 'expire_signal_out'),
                         (self.inets_carrier_sensing_0, 'cmd_in'))
        self.msg_connect((self.inets_general_timer_1_0, 'expire_signal_out'),
                         (self.inets_carrier_sensing_0_1, 'cmd_in'))
        self.msg_connect((self.inets_general_timer_2, 'expire_signal_out'),
                         (self.inets_cogmac_ch_pool_0, 'CCA_CH_in'))
        self.msg_connect((self.inets_general_timer_2, 'expire_signal_out'),
                         (self.inets_frame_path_0, 'frame_in'))
        self.msg_connect((self.inets_general_timer_2, 'expire_signal_out'),
                         (self.inets_frame_path_2_0, 'frame_in'))
        self.msg_connect((self.inets_general_timer_2_0, 'expire_signal_out'),
                         (self.inets_frame_path_1_0_0, 'frame_in'))
        self.msg_connect((self.inets_general_timer_3, 'expire_signal_out'),
                         (self.inets_carrier_sensing_0_0, 'cmd_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_power_out'),
                         (self.inets_carrier_sensing_0, 'power_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_power_out'),
                         (self.inets_carrier_sensing_0_0, 'power_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_power_out'),
                         (self.inets_carrier_sensing_0_1, 'power_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_frame_out'),
                         (self.inets_frame_analysis_0, 'frame_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_switch_out'),
                         (self.inets_sending_0, 'in'))
        self.msg_connect((self.inets_run_0, 'trigger_out'),
                         (self.inets_cogmac_timing_0, 'trigger_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'),
                         (self.inets_frame_index_selector_0_1, 'frame_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'),
                         (self.inets_frame_path_2, 'frame_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'),
                         (self.inets_frame_probe_0, 'info_in'))
        self.msg_connect((self.inets_sending_0, 'rx_control_out'),
                         (self.inets_receiving_0, 'rx_switch_in'))
        self.msg_connect((self.inets_unbundle_0, 'cmd_out'),
                         (self.inets_frame_replicate_0, 'reset_number_in'))
        self.msg_connect((self.inets_unbundle_0_0, 'cmd_out'),
                         (self.inets_frame_counter_1, 'set_n_counts_in'))
        self.msg_connect((self.inets_unbundle_0_0_0, 'cmd_out'),
                         (self.inets_carrier_sensing_0, 'reset_duration_in'))
        self.msg_connect((self.inets_unbundle_0_0_0, 'cmd_out'),
                         (self.inets_carrier_sensing_0_1, 'reset_duration_in'))
        self.msg_connect((self.inets_unbundle_0_0_0_0, 'cmd_out'),
                         (self.inets_frame_buffer_0_0, 'reset_size_in'))
        self.msg_connect((self.inets_unbundle_0_0_0_0_0, 'cmd_out'),
                         (self.inets_frame_buffer_0, 'reset_size_in'))
Ejemplo n.º 3
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_multichannel")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_multichannel")
        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", "Test_multichannel")
        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.usrp_device_address = usrp_device_address = "addr=10.0.0.20"
        self.tx_center_frequency = tx_center_frequency = 3.9e8
        self.system_time_granularity_us = system_time_granularity_us = 1000
        self.source_address = source_address = 2
        self.samp_rate = samp_rate = 1000000
        self.rx_gain = rx_gain = range_rx_gain
        self.rx_center_frequency = rx_center_frequency = 3.9e8

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

        self.mu = mu = range_mu
        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.destination_address = destination_address = 1
        self.cs_threshold = cs_threshold = 0.005

        ##################################################
        # Blocks
        ##################################################
        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_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.inets_receiving_0 = inets.receiving(
            1, 21,
            gnuradio.digital.constellation_qpsk().base(), rrc, mu,
            diff_preamble_128, rx_gain, samp_rate, sps, 30,
            usrp_device_address, rx_center_frequency)
        self.inets_frame_probe_0_0 = inets.frame_probe(1, 100, 0, 0, 0.01)
        self.inets_frame_probe_0 = inets.frame_probe(0, 100, 0, 0, 0.01)
        self.inets_frame_analysis_0 = inets.frame_analysis(
            0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address)
        self.inets_cogmac_ch_pool_0 = inets.cogmac_ch_pool(
            1, 35, 3, 390000000, 0, 10000000)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("TEST"), 1000)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.inets_cogmac_ch_pool_0, 'change_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'next_frequency_out'),
                         (self.inets_receiving_0, 'rx_frequency_in'))
        self.msg_connect((self.inets_frame_analysis_0, 'frame_info_out'),
                         (self.inets_frame_probe_0, 'info_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_frame_out'),
                         (self.inets_frame_analysis_0, 'frame_in'))