def runIt(self, inputFilename, outputFilename, rowPoly, colPoly, kRow, kCol, B, Q): inputData = self.readBinaryFile(os.path.join(self.testFilesDir, inputFilename)) expectedOutputData = self.readBinaryFile(os.path.join(self.testFilesDir, outputFilename)) # define the required components self.variable_cc_def_fecapi_tpc_encoder_def_0 = \ variable_cc_def_fecapi_tpc_encoder_def_0 = \ map( (lambda a: fec.tpc_make_encoder((rowPoly), (colPoly), kRow, kCol, B, Q)), range(0,1) ); self.encoder_interface_0 = \ extended_encoder_interface(encoder_obj_list=variable_cc_def_fecapi_tpc_encoder_def_0, threading='capillary', puncpat='11', ) # setup connections of flowgraph self.blocks_vector_source_x_0 = blocks.vector_source_b(inputData, False, 1, []) self.blocks_vector_sink_x_0 = blocks.vector_sink_f(1) self.tb.connect((self.blocks_vector_source_x_0, 0), (self.encoder_interface_0, 0)) self.tb.connect((self.encoder_interface_0, 0), (self.blocks_vector_sink_x_0, 0)) # run the block self.tb.run() # check output versus expectedOutputData actualOutputData = self.blocks_vector_sink_x_0.data() outputLen = len(expectedOutputData) self.assertFloatTuplesAlmostEqual(expectedOutputData, actualOutputData, outputLen)
def __init__(self, generic_encoder=0, generic_decoder=0, esno=0, berminerrors=100, samp_rate=32000, berlimit=-5.0, threading="capillary", puncpat='11'): gr.hier_block2.__init__( self, "BER Generator", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_float*1), ) ################################################## # Parameters ################################################## self.generic_encoder = generic_encoder self.generic_decoder = generic_decoder self.esno = esno self.berminerrors = berminerrors self.samp_rate = samp_rate self.berlimit = berlimit self.threading = threading self.puncpat = puncpat ################################################## # Blocks ################################################## self.random_gen_b_0 = fec.random_gen_b(0) #self.puncture_ff_0 = fec.puncture_ff(0, read_bitlist(puncpat), puncpat.count('0'), len(puncpat)) self.gr_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST) self.gr_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST) self.gr_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate) #self.generic_encoder_0 = fec.encoder(generic_encoder, gr.sizeof_char, gr.sizeof_float) self.encoder_interface_0 = extended_encoder_interface(encoder_obj_list=generic_encoder, threading='capillary', puncpat=puncpat); self.gaussnoise_ff_0 = fec.gaussnoise_ff(esno) self.decoder_interface_0 = extended_decoder_interface(decoder_obj_list=generic_decoder, threading='capillary', ann=None, puncpat=puncpat, integration_period=10000, rotator=None) self.ber_bb_0_0 = fec.ber_bb(berminerrors, berlimit) ################################################## # Connections ################################################## self.connect((self.gr_unpacked_to_packed_xx_0_0, 0), (self.ber_bb_0_0, 0)) self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.ber_bb_0_0, 1)) #self.connect((self.gr_throttle_0, 0), (self.generic_encoder_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_unpacked_to_packed_xx_0, 0)) self.connect((self.ber_bb_0_0, 0), (self, 0)) self.connect((self.decoder_interface_0, 0), (self.gr_unpacked_to_packed_xx_0_0, 0)) #self.connect((self.generic_encoder_0, 0), (self.puncture_ff_0, 0)) #self.connect((self.puncture_ff_0, 0), (self.gaussnoise_ff_0, 0)) self.connect((self.gaussnoise_ff_0, 0), (self.decoder_interface_0, 0)) self.connect((self.random_gen_b_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_throttle_0, 0), (self.encoder_interface_0, 0)) self.connect((self.encoder_interface_0, 0), (self.gaussnoise_ff_0, 0))
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 ################################################## None self.variable_cc_def_fecapi_tpc_encoder_def_0 = variable_cc_def_fecapi_tpc_encoder_def_0 = map( (lambda a: fec.tpc_make_encoder(([3]), ([43]), 26, 6, 9, 3)), range(0, 1)) self.variable_cc_def_fecapi_tpc_decoder_def_0 = variable_cc_def_fecapi_tpc_decoder_def_0 = map( (lambda a: fec.tpc_make_decoder(([3]), ([43]), 26, 6, 9, 3, 2, 1)), range(0, 1)) self.samp_rate = samp_rate = 10e6 self.num_samps_per_block = num_samps_per_block = 144 self.num_blocks = num_blocks = 2 ################################################## # Blocks ################################################## self.variable_decoder_interface_0 = variable_decoder_interface_0 = extended_decoder_interface( decoder_obj_list=variable_cc_def_fecapi_tpc_decoder_def_0, threading='capillary', ann=None, puncpat='11', integration_period=10000) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( num_samps_per_block * num_blocks, #size samp_rate, #samp_rate "FEC IO DIFF", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_win) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f( num_samps_per_block * num_blocks, #size samp_rate, #samp_rate "DECODER_INPUT", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( num_samps_per_block * num_blocks, #size samp_rate, #samp_rate "FEC INPUT", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.encoder_interface_0 = extended_encoder_interface( encoder_obj_list=variable_cc_def_fecapi_tpc_encoder_def_0, threading='capillary', puncpat='11', ) self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_sub_xx_1 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_ctrlport_monitor_0 = not True or monitor() self.analog_random_source_x_0 = blocks.vector_source_b( map( int, numpy.random.randint(0, 2, num_samps_per_block * num_blocks * 100)), True) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 1) ################################################## # Connections ################################################## self.connect((self.variable_decoder_interface_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_sub_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.variable_decoder_interface_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_uchar_to_float_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.encoder_interface_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.blocks_sub_xx_1, 1)) self.connect((self.encoder_interface_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_sub_xx_0, 0))
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 ################################################## None self.variable_cc_def_fecapi_encoder_def_0 = variable_cc_def_fecapi_encoder_def_0 = map( (lambda a: fec.cc_make_encoder(2048, 7, 2, ([79, 109]), 0, -1, False, False, False, True)), range(0, 1)) self.variable_cc_def_fecapi_decoder_def_0 = variable_cc_def_fecapi_decoder_def_0 = map( (lambda a: fec.cc_make_decoder(2048, 7, 2, ([79, 109]), 0, -1, False, False, False, True)), range(0, 1)) self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.variable_decoder_interface_0 = variable_decoder_interface_0 = extended_decoder_interface( decoder_obj_list=variable_cc_def_fecapi_decoder_def_0, threading='capillary', ann=None, puncpat='11', integration_period=10000) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.encoder_interface_0 = extended_encoder_interface( encoder_obj_list=variable_cc_def_fecapi_encoder_def_0, threading='capillary', puncpat='11', ) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, 4096)), False) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.encoder_interface_0, 0)) self.connect((self.encoder_interface_0, 0), (self.variable_decoder_interface_0, 0)) self.connect((self.variable_decoder_interface_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_1, 0))