""" GNU Radio Companion is a graphical interface into the GNU Radio project. Copyright (C) 2007 Josh Blum GNU Radio Companion is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GNU Radio Companion is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ """ SignalBlockDefs/Misc.py Josh Blum These blocks were not categorized. Try to keep the number of misc blocks small. """ from DataType import * from gnuradio import gr from SignalBlockDefs import * def Encoder(sb): import Constants from gnuradio import trellis type = Enum([('Byte-->Byte', (trellis.encoder_bb, Byte(),Byte())), ('Byte-->Short', (trellis.encoder_bs, Byte(),Short())), ('Byte-->Int', (trellis.encoder_bi, Byte(),Int())), ('Short-->Short', (trellis.encoder_ss, Short(),Short())), ('Short-->Int', (trellis.encoder_si, Short(),Int())), ('Int-->Int', (trellis.encoder_ii, Int(),Int())), ],3) fcn = type.parse()[0] sb.add_input_socket('in', Variable(type, index=1)) sb.add_output_socket('out', Variable(type, index=2)) sb.add_param('Type', type, False, type=True) sb.add_param('File Path', FileOpen(Constants.DEFAULT_FILE_PATH)) sb.add_param('Initial State', Int()) sb.set_docs('''Trellis Encoder. For the time being the underlying FSM can only be read from a file...''') def make(fg, type, filename, s0): fsm=trellis.fsm(filename.parse()) # not sure if this is the right way to do this... block = fcn[0](fsm, s0.parse()) return block return sb, make def Metrics(sb): from gnuradio import trellis type = Enum([('Complex', (trellis.metrics_c, Complex())), ('Float', (trellis.metrics_f, Float())), ('Int', (trellis.metrics_i, Int())), ('Short', (trellis.metrics_s, Short())),],1) fcn = type.parse()[0] sb.add_input_socket('in', Variable(type, index=1)) sb.add_output_socket('out', Variable(type, index=1)) sb.add_param('Type', type, False, type=True) sb.add_param('Output cardinality', Int()) sb.add_param('Dimensionality', Int()) sb.add_param('Constellation', FloatVector()) sb.add_param('Metric Type', Enum([('Euclidean', trellis.TRELLIS_EUCLIDEAN), ('Hard Symbol', trellis.TRELLIS_HARD_SYMBOL), ('Hard Bit', trellis.TRELLIS_HARD_BIT)],0)) sb.set_docs('''Generate the metrics block from gr-trellis.''') def make(fg, type, O, D, Con, MetrType): block = fcn[0](O.parse(), D.parse(), Con.parse(), MetrType.parse()) return block return sb, make def Viterbi(sb): import Constants from gnuradio import trellis type = Enum([('Byte', (trellis.viterbi_b, Byte())), ('Short', (trellis.viterbi_s, Short())), ('Int', (trellis.viterbi_i, Int())), ],1) fcn = type.parse()[0] sb.add_input_socket('in', Float()) sb.add_output_socket('out', Variable(type, index=1)) sb.add_param('Type', type, False, type=True) sb.add_param('File Path', FileOpen(Constants.DEFAULT_FILE_PATH)) sb.add_param('Length', Int()) sb.add_param('Initial State', Int()) sb.add_param('Final State', Int()) sb.set_docs('''Viterbi Decoder. FSM is specified through its filnemae only...''') def make(fg, type, filename, K, s0, sK): fsm=trellis.fsm(filename.parse()) block = fcn[0](fsm, K.parse(), s0.parse(), sK.parse()) return block return sb, make def Viterbi_Combined(sb): import Constants from gnuradio import trellis type = Enum([('Byte', (trellis.viterbi_combined_b, Byte())), ('Short', (trellis.viterbi_combined_s, Short())), ('Int', (trellis.viterbi_combined_i, Int())), ],1) fcn = type.parse()[0] sb.add_input_socket('in', Float()) sb.add_output_socket('out', Variable(type, index=1)) sb.add_param('Type', type, False, type=True) sb.add_param('File Path', FileOpen(Constants.DEFAULT_FILE_PATH)) sb.add_param('Length', Int()) sb.add_param('Initial State', Int()) sb.add_param('Final State', Int()) sb.add_param('Dimensionality', Int()) sb.add_param('Constellation', FloatVector()) sb.add_param('Metric Type', Enum([('Euclidean', trellis.TRELLIS_EUCLIDEAN), ('Hard Symbol', trellis.TRELLIS_HARD_SYMBOL), ('Hard Bit', trellis.TRELLIS_HARD_BIT)],0)) sb.set_docs('''Viterbi Decoder combined with metric calculation. FSM is specified through its filnemae only...''') def make(fg, type, filename, K, s0, sK, D, Con, MetrType): fsm=trellis.fsm(filename.parse()) block = fcn[0](fsm, K.parse(), s0.parse(), sK.parse(), D.parse(), Con.parse(), MetrType.parse()) return block return sb, make