def test_and_ii (self):
     src1_data =       (1,  2,  3,  0x50005004,   0x11001150)
     src2_data =       (8,  2,  1 , 0x05000508,   0x11001105)
     expected_result = (0,  2,  1,  0x00000000,   0x11001100)
     op = blocks.and_ii ()
     self.help_ii ((src1_data, src2_data),
                   expected_result, op)
 def test_and_ii (self):
     src1_data =       [1,  2,  3,  0x50005004,   0x11001150]
     src2_data =       [8,  2,  1 , 0x05000508,   0x11001105]
     expected_result = [0,  2,  1,  0x00000000,   0x11001100]
     op = blocks.and_ii ()
     self.help_ii ((src1_data, src2_data),
                   expected_result, op)
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1000000
        self.Ns = Ns = 1000000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_VERT,
            3
        )
        self.qtgui_number_sink_0.set_update_time(0.30)
        self.qtgui_number_sink_0.set_title("")
        
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        units = ['', '', '', '', '',
                 '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(3):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])
        
        self.qtgui_number_sink_0.enable_autoscale(True)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.blocks_throttle_0_0_0 = blocks.throttle(gr.sizeof_int*1, samp_rate,True)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_int*1, samp_rate,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_int*1, samp_rate,True)
        self.blocks_and_xx_0 = blocks.and_ii()
        self.analog_random_source_x_0_0 = blocks.vector_source_i(map(int, numpy.random.randint(0, 2, Ns)), True)
        self.analog_random_source_x_0 = blocks.vector_source_i(map(int, numpy.random.randint(0, 2, Ns)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_and_xx_0, 0))    
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0_0, 0))    
        self.connect((self.analog_random_source_x_0_0, 0), (self.blocks_and_xx_0, 1))    
        self.connect((self.analog_random_source_x_0_0, 0), (self.blocks_throttle_0_0_0, 0))    
        self.connect((self.blocks_and_xx_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_number_sink_0, 2))    
        self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_number_sink_0, 0))    
        self.connect((self.blocks_throttle_0_0_0, 0), (self.qtgui_number_sink_0, 1))    
Esempio n. 4
0
 def test_and_ii(self):
     src1_data = (1, 2, 3, 0x50005004, 0x11001150)
     src2_data = (8, 2, 1, 0x05000508, 0x11001105)
     expected_result = (0, 2, 1, 0x00000000, 0x11001100)
     op = blocks.and_ii()
     self.help_ii((src1_data, src2_data), expected_result, op)