1#!/usr/bin/env python
2#
3# Copyright 2014 Free Software Foundation, Inc.
4#
5# This file is part of GNU Radio
6#
7# GNU Radio is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3, or (at your option)
10# any later version.
11#
12# GNU Radio is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with GNU Radio; see the file COPYING.  If not, write to
19# the Free Software Foundation, Inc., 51 Franklin Street,
20# Boston, MA 02110-1301, USA.
21#
22
23from __future__ import unicode_literals
24from gnuradio import gr, blocks
25from . import fec_swig as fec
26
27
28class threaded_decoder(gr.hier_block2):
29    def __init__(self, decoder_list_0, input_size, output_size):
30        gr.hier_block2.__init__(
31            self, "Threaded Decoder",
32            gr.io_signature(1, 1, input_size*1),
33            gr.io_signature(1, 1, output_size*1))
34
35        self.decoder_list_0 = decoder_list_0
36
37        self.deinterleave_0 = blocks.deinterleave(input_size,
38                                                  fec.get_decoder_input_size(decoder_list_0[0]))
39
40        self.generic_decoders_0 = []
41        for i in range(len(decoder_list_0)):
42            self.generic_decoders_0.append(fec.decoder(decoder_list_0[i],
43                                                       input_size, output_size))
44
45        self.interleave_0 = blocks.interleave(output_size,
46                                              fec.get_decoder_output_size(decoder_list_0[0]))
47
48        for i in range(len(decoder_list_0)):
49            self.connect((self.deinterleave_0, i), (self.generic_decoders_0[i], 0))
50
51        for i in range(len(decoder_list_0)):
52            self.connect((self.generic_decoders_0[i], 0), (self.interleave_0, i))
53
54
55        self.connect((self, 0), (self.deinterleave_0, 0))
56        self.connect((self.interleave_0, 0), (self, 0))
57
58    def get_decoder_list_0(self):
59        return self.decoder_list_0
60
61    def set_decoder_list_0(self, decoder_list_0):
62        self.decoder_list_0 = decoder_list_0
63