def __init__($param_str):
gr.top_block.__init__(self, "$title")
#elif $generate_options == 'hb'
- #set $in_sig = $flow_graph.get_input_signature()
- #set $out_sig = $flow_graph.get_output_signature()
+ #set $in_sigs = $flow_graph.get_input_signaturev()
+ #set $out_sigs = $flow_graph.get_output_signaturev()
class $(class_name)(gr.hier_block2):
+#def make_io_sig($io_sigs)
+ #set $size_strs = ['%s*%s'%(io_sig['size'], io_sig['vlen']) for io_sig in $io_sigs]
+ #if len($io_sigs) == 0
+gr.io_signature(0, 0, 0)#slurp
+ #elif len($io_sigs) == 1
+gr.io_signature(1, 1, $size_strs[0])#slurp
+ #else
+gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])#slurp
+ #end if
+#end def
def __init__($param_str):
gr.hier_block2.__init__(
self, "$title",
- gr.io_signature($in_sig.nports, $in_sig.nports, $in_sig.size*$in_sig.vlen),
- gr.io_signature($out_sig.nports, $out_sig.nports, $out_sig.size*$out_sig.vlen),
+ $make_io_sig($in_sigs),
+ $make_io_sig($out_sigs),
)
#end if
########################################################
$DIVIDER
#end if
#for $msg in $messages
- $(msg.get_source().get_parent().get_id())_msgq = $(msg.get_sink().get_parent().get_id())_msgq = gr.msg_queue(2)
+ $(msg.get_source().get_parent().get_id())_msgq_out = $(msg.get_sink().get_parent().get_id())_msgq_in = gr.msg_queue(2)
#end for
########################################################
##Create Blocks
## The port name should be the id of the parent block.
## However, port names for IO pads should be self.
########################################################
+#def make_port_name($port)
+ #if $port.get_parent().get_key().startswith('pad_')
+self#slurp
+ #else
+self.$port.get_parent().get_id()#slurp
+ #end if
+#end def
#if $connections
$DIVIDER
$DIVIDER
#end if
#for $con in $connections
- ####################################################################
- ## Logic to extract source and sink
- ## Special resolution logic for pad source in continuation mode
- ####################################################################
#set $source = $con.get_source()
#set $sink = $con.get_sink()
- #if $source.get_parent().get_key() == 'pad_source' and $source.get_parent().get_param('mode').get_value() == 'cont'
- #set $pad_sink_id = $source.get_parent().get_param('pad_sink_id').get_evaluated()
- #set $pad_sink = filter(lambda b: b.get_id() == pad_sink_id, $blocks)[0]
- #set $source = $pad_sink.get_sink($source.get_key()).get_connections()[0].get_source()
+ ##resolve virtual sources to the actual sources
+ #if $source.get_parent().is_virtual_source()
+ #set $source = $source.resolve_virtual_source()
#end if
- ####################################################################
- ## Logic to extract source and sink names
- ####################################################################
- #if $source.get_parent().get_key() == 'pad_source'
- #set $source_name = 'self'
- #else
- #set $source_name = 'self.' + $source.get_parent().get_id()
- #end if
- #if $sink.get_parent().get_key() == 'pad_sink'
- #set $sink_name = 'self'
- #else
- #set $sink_name = 'self.' + $sink.get_parent().get_id()
- #end if
- ####################################################################
- ## Dont make a connection for continuation pad sinks!!!
- ####################################################################
- #if not ($sink.get_parent().get_key() == 'pad_sink' and $sink.get_parent().get_param('mode').get_value() == 'cont')
- self.connect(($source_name, $source.get_key()), ($sink_name, $sink.get_key()))
+ ##do not generate connections with virtual sinks
+ #if not $sink.get_parent().is_virtual_sink()
+ self.connect(($make_port_name($source), $source.get_key()), ($make_port_name($sink), $sink.get_key()))
#end if
#end for
#if $generate_options == 'wx_gui'
tb.Run($flow_graph.get_option('run'))
#elif $generate_options == 'no_gui'
+ #set $run_options = $flow_graph.get_option('run_options')
+ #if $run_options == 'prompt'
tb.start()
raw_input('Press Enter to quit: ')
tb.stop()
+ #elif $run_options == 'run'
+ tb.run()
+ #end if
#end if
#end if