def __init__(self,
                 max_freq_offset=10,
                 guard=0.125,
                 mode=3,
                 snr=10,
                 tmcc_print=False):
        gr.hier_block2.__init__(
            # self, "ISDB-T RF Channel Decoding",
            self,
            "isdbt_rf_channel_decoding",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signaturev(2, 2, [
                gr.sizeof_gr_complex * 13 * 96 * 2**(mode - 1),
                gr.sizeof_gr_complex * (13 * 108 * 2**(mode - 1) + 1)
            ]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.max_freq_offset = max_freq_offset
        self.guard = guard
        self.mode = mode
        self.snr = snr
        self.tmcc_print = tmcc_print

        ##################################################
        # Variables
        ##################################################
        self.total_carriers = total_carriers = 2**(10 + mode)
        self.data_carriers = data_carriers = 13 * 96 * 2**(mode - 1)
        self.active_carriers = active_carriers = 13 * 108 * 2**(mode - 1) + 1

        ##################################################
        # Blocks
        ##################################################
        self.isdbt_tmcc_decoder_0 = isdbt.tmcc_decoder(mode, tmcc_print)
        self.isdbt_sync_and_channel_estimaton_0 = isdbt.sync_and_channel_estimaton(
            total_carriers, active_carriers, max_freq_offset)
        self.isdbt_ofdm_sym_acquisition_0 = isdbt.ofdm_sym_acquisition(
            total_carriers, int(guard * total_carriers), snr)
        self.fft_vxx_0 = fft.fft_vcc(total_carriers, True,
                                     (window.rectangular(total_carriers)),
                                     True, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fft_vxx_0, 0),
                     (self.isdbt_sync_and_channel_estimaton_0, 0))
        self.connect((self.isdbt_ofdm_sym_acquisition_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.isdbt_sync_and_channel_estimaton_0, 0),
                     (self.isdbt_tmcc_decoder_0, 0))
        self.connect((self.isdbt_sync_and_channel_estimaton_0, 1), (self, 1))
        self.connect((self.isdbt_tmcc_decoder_0, 0), (self, 0))
        self.connect((self, 0), (self.isdbt_ofdm_sym_acquisition_0, 0))
    def test_001_t(self):
        # set up fg

        total_segments = 13
        mode = 1
        total_carriers = total_segments * 108 * 2**(mode - 1) + 1
        fft_size = 2**(10 + mode)
        sync = isdbt.sync_and_channel_estimaton(fft_size, total_carriers, 200)

        src_data = range(fft_size) * 2

        src = blocks.vector_source_c(src_data, False, fft_size)
        dst = blocks.vector_sink_c(total_carriers)

        self.tb.connect(src, sync)
        self.tb.connect(sync, dst)
        self.tb.run()

        actual_result = dst.data()
    def test_001_t (self):
        # set up fg

        total_segments = 13; 
        mode = 1; 
        total_carriers = total_segments*108*2**(mode-1)+1
        fft_size = 2**(10+mode)
        sync = isdbt.sync_and_channel_estimaton(fft_size, total_carriers,200)

        src_data = range(fft_size)*2
        
        src = blocks.vector_source_c(src_data, False, fft_size)
        dst = blocks.vector_sink_c(total_carriers)

        self.tb.connect(src, sync)
        self.tb.connect(sync,dst)
        self.tb.run()

        actual_result = dst.data()
    def __init__(self, max_freq_offset=10, guard=0.125, mode=3, snr=10, tmcc_print=False):
        gr.hier_block2.__init__(
           # self, "ISDB-T RF Channel Decoding",
            self, "isdbt_rf_channel_decoding",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signaturev(2, 2, [gr.sizeof_gr_complex*13*96*2**(mode-1), gr.sizeof_gr_complex*(13*108*2**(mode-1)+1)]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.max_freq_offset = max_freq_offset
        self.guard = guard
        self.mode = mode
        self.snr = snr
        self.tmcc_print = tmcc_print

        ##################################################
        # Variables
        ##################################################
        self.total_carriers = total_carriers = 2**(10+mode)
        self.data_carriers = data_carriers = 13*96*2**(mode-1)
        self.active_carriers = active_carriers = 13*108*2**(mode-1)+1

        ##################################################
        # Blocks
        ##################################################
        self.isdbt_tmcc_decoder_0 = isdbt.tmcc_decoder(mode, tmcc_print)
        self.isdbt_sync_and_channel_estimaton_0 = isdbt.sync_and_channel_estimaton(total_carriers, active_carriers, max_freq_offset)
        self.isdbt_ofdm_sym_acquisition_0 = isdbt.ofdm_sym_acquisition(total_carriers, int(guard*total_carriers), snr)
        self.fft_vxx_0 = fft.fft_vcc(total_carriers, True, (window.rectangular(total_carriers)), True, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.fft_vxx_0, 0), (self.isdbt_sync_and_channel_estimaton_0, 0))    
        self.connect((self.isdbt_ofdm_sym_acquisition_0, 0), (self.fft_vxx_0, 0))    
        self.connect((self.isdbt_sync_and_channel_estimaton_0, 0), (self.isdbt_tmcc_decoder_0, 0))
        self.connect((self.isdbt_sync_and_channel_estimaton_0, 1), (self, 1))
        self.connect((self.isdbt_tmcc_decoder_0, 0), (self, 0))    
        self.connect((self, 0), (self.isdbt_ofdm_sym_acquisition_0, 0))