#
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008, 2009 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
#
include $(top_srcdir)/Makefile.common
-grc_src_prefix = $(pythondir)/gnuradio/grc
+grc_src_prefix = $(pkgpythondir)/grc
grc_blocksdir = $(pkgdatadir)/grc/blocks
return self._param.get_evaluated()
def _get_keys(lst): return [elem.get_key() for elem in lst]
-def _get_elem(lst, key): return lst[_get_keys(lst).index(key)]
+def _get_elem(lst, key):
+ try: return lst[_get_keys(lst).index(key)]
+ except ValueError: raise ValueError, 'Key "%s" not found in %s.'%(key, _get_keys(lst))
class Block(Element):
self.get_params().append(param)
#create the source objects
self._sources = list()
- for source in map(lambda n: self.get_parent().get_parent().Source(self, n), sources):
+ for source in map(lambda n: self.get_parent().get_parent().Port(self, n, dir='source'), sources):
key = source.get_key()
#test against repeated keys
try: assert key not in self.get_source_keys()
self.get_sources().append(source)
#create the sink objects
self._sinks = list()
- for sink in map(lambda n: self.get_parent().get_parent().Sink(self, n), sinks):
+ for sink in map(lambda n: self.get_parent().get_parent().Port(self, n, dir='sink'), sinks):
key = sink.get_key()
#test against repeated keys
try: assert key not in self.get_sink_keys()
FlowGraph = _FlowGraph
Connection = _Connection
Block = _Block
- Source = _Port
- Sink = _Port
+ Port = _Port
Param = _Param
##possible port types
TYPES = []
- def __init__(self, block, n):
+ def __init__(self, block, n, dir):
"""
Make a new port from nested data.
@param block the parent element
@param n the nested odict
- @return a new port
+ @param dir the direction source or sink
"""
- #grab the data
- name = n['name']
- key = n['key']
- type = n['type']
#build the port
Element.__init__(self, block)
- self._name = name
- self._key = key
- self._type = type
+ #grab the data
+ self._name = n['name']
+ self._key = n['key']
+ self._type = n['type']
+ self._dir = dir
def validate(self):
"""
def get_color(self): return '#FFFFFF'
def get_name(self): return self._name
def get_key(self): return self._key
- def is_sink(self): return self in self.get_parent().get_sinks()
- def is_source(self): return self in self.get_parent().get_sources()
+ def is_sink(self): return self._dir == 'sink'
+ def is_source(self): return self._dir == 'source'
def get_type(self): return self.get_parent().resolve_dependencies(self._type)
def get_connections(self):
<name>Pad Sink</name>
<key>pad_sink</key>
<make></make>
+ <param>
+ <name>Mode</name>
+ <key>mode</key>
+ <value>hb</value>
+ <type>enum</type>
+ <option>
+ <name>Hierarchical</name>
+ <key>hb</key>
+ </option>
+ <option>
+ <name>Continuation</name>
+ <key>cont</key>
+ </option>
+ </param>
<param>
<name>Num Inputs</name>
<key>nports</key>
<nports>$nports</nports>
</sink>
<doc>
-This is a sink pad block for creating hierarchical flow graphs. \
+Continuation Mode:
+The inputs of this block can be aliased by one or more pad source blocks.
+
+Hierarchical Mode:
The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. \
Limit one sink pad block per flow graph.
-
-Remember to set the generate options to hier block.
</doc>
</block>
<name>Pad Source</name>
<key>pad_source</key>
<make></make>
+ <param>
+ <name>Mode</name>
+ <key>mode</key>
+ <value>hb</value>
+ <type>enum</type>
+ <option>
+ <name>Hierarchical</name>
+ <key>hb</key>
+ </option>
+ <option>
+ <name>Continuation</name>
+ <key>cont</key>
+ </option>
+ </param>
<param>
<name>Num Outputs</name>
<key>nports</key>
<value>1</value>
<type>int</type>
</param>
+ <param>
+ <name>Pad Sink ID</name>
+ <key>pad_sink_id</key>
+ <value>pad_sink_0</value>
+ <type>string</type>
+ <hide>#if $mode() == 'cont' then 'none' else 'all'#</hide>
+ </param>
<check>$vlen > 0</check>
<check>0 < $nports</check>
<source>
<nports>$nports</nports>
</source>
<doc>
-This is a source pad block for creating hierarchical flow graphs. \
-The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. \
-Limit one source pad block per flow graph.
+Continuation Mode:
+The outputs of this block will alias the inputs of the pad sink specified by "pad sink id".
-Remember to set the generate options to hier block.
+Hierarchical Mode:
+The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. \
+Limit one source pad block per flow graph. \
+The "pad sink id" will be ignored in this mode.
</doc>
</block>
Actions.FLOW_GRAPH_OPEN, Actions.FLOW_GRAPH_SAVE_AS,
Actions.FLOW_GRAPH_CLOSE, Actions.ABOUT_WINDOW_DISPLAY,
Actions.FLOW_GRAPH_SCREEN_CAPTURE, Actions.HELP_WINDOW_DISPLAY,
- Actions.COLORS_WINDOW_DISPLAY,
+ Actions.TYPES_WINDOW_DISPLAY,
): Actions.get_action_from_name(action).set_sensitive(True)
if not self.init_file_paths:
self.init_file_paths = Preferences.files_open()
Dialogs.AboutDialog(self.get_flow_graph().get_parent())
elif state == Actions.HELP_WINDOW_DISPLAY:
Dialogs.HelpDialog()
- elif state == Actions.COLORS_WINDOW_DISPLAY:
- Dialogs.ColorsDialog(self.get_flow_graph().get_parent())
+ elif state == Actions.TYPES_WINDOW_DISPLAY:
+ Dialogs.TypesDialog(self.get_flow_graph().get_parent())
##################################################
# Param Modifications
##################################################
FLOW_GRAPH_SCREEN_CAPTURE = 'flow graph screen capture'
ABOUT_WINDOW_DISPLAY = 'about window display'
HELP_WINDOW_DISPLAY = 'help window display'
-COLORS_WINDOW_DISPLAY = 'colors window display'
+TYPES_WINDOW_DISPLAY = 'types window display'
######################################################################################################
# Action Key Map
gtk.Action(BLOCK_PASTE, '_Paste', 'Paste', gtk.STOCK_PASTE),
gtk.Action(ABOUT_WINDOW_DISPLAY, '_About', 'About this program', gtk.STOCK_ABOUT),
gtk.Action(HELP_WINDOW_DISPLAY, '_Help', 'Usage Tips', gtk.STOCK_HELP),
- gtk.Action(COLORS_WINDOW_DISPLAY, '_Colors', 'Color Mapping', gtk.STOCK_DIALOG_INFO),
+ gtk.Action(TYPES_WINDOW_DISPLAY, '_Types', 'Types Color Mapping', gtk.STOCK_DIALOG_INFO),
gtk.Action(FLOW_GRAPH_GEN, '_Generate', 'Generate the flow graph', gtk.STOCK_CONVERT),
gtk.Action(FLOW_GRAPH_EXEC, '_Execute', 'Execute the flow graph', gtk.STOCK_EXECUTE),
gtk.Action(FLOW_GRAPH_KILL, '_Kill', 'Kill the flow graph', gtk.STOCK_STOP),
]),
(gtk.Action('Help', '_Help', None, None), [
Actions.HELP_WINDOW_DISPLAY,
- Actions.COLORS_WINDOW_DISPLAY,
+ Actions.TYPES_WINDOW_DISPLAY,
None,
Actions.ABOUT_WINDOW_DISPLAY,
]),
#end if
"""
-def ColorsDialog(platform): MessageDialogHelper(
+def TypesDialog(platform): MessageDialogHelper(
type=gtk.MESSAGE_INFO,
buttons=gtk.BUTTONS_CLOSE,
- title='Colors',
+ title='Types',
markup=Utils.parse_template(COLORS_DIALOG_MARKUP_TMPL, colors=platform.get_colors()))
"""
-Copyright 2008 Free Software Foundation, Inc.
+Copyright 2008, 2009 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
('FlowGraph', FlowGraph),
('Connection', Connection),
('Block', Block),
- ('Source', Port),
- ('Sink', Port),
+ ('Port', Port),
('Param', Param),
):
old_value = getattr(platform, attr)
"""
-Copyright 2007 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
from FlowGraph import FlowGraph as _FlowGraph
from Connection import Connection as _Connection
from Block import Block as _Block
-from Port import Source,Sink
+from Port import Port as _Port
from Param import Param as _Param
from Generator import Generator
from Constants import \
FlowGraph = _FlowGraph
Connection = _Connection
Block = _Block
- Source = Source
- Sink = Sink
+ Port = _Port
Param = _Param
##possible port types
TYPES = ['complex', 'float', 'int', 'short', 'byte', 'msg']
- def __init__(self, block, n):
+ def __init__(self, block, n, dir):
"""
Make a new port from nested data.
@param block the parent element
@param n the nested odict
+ @param dir the direction
"""
+ self._n = n
+ if n['type'] == 'msg': n['key'] = 'msg'
+ if dir == 'source' and not n.find('key'):
+ n['key'] = str(block._source_count)
+ block._source_count += 1
+ if dir == 'sink' and not n.find('key'):
+ n['key'] = str(block._sink_count)
+ block._sink_count += 1
#build the port
_Port.__init__(
self,
block=block,
n=n,
+ dir=dir,
)
self._nports = n.find('nports') or ''
self._vlen = n.find('vlen') or ''
def copy(self, new_key=None):
n = self._n.copy()
if new_key: n['key'] = new_key
- return self.__class__(self.get_parent(), n)
-
-class Source(Port):
-
- def __init__(self, block, n):
- self._n = n #save n
- if n['type'] == 'msg': n['key'] = 'msg'
- if not n.find('key'):
- n['key'] = str(block._source_count)
- block._source_count = block._source_count + 1
- Port.__init__(self, block, n)
-
-class Sink(Port):
-
- def __init__(self, block, n):
- self._n = n #save n
- if n['type'] == 'msg': n['key'] = 'msg'
- if not n.find('key'):
- n['key'] = str(block._sink_count)
- block._sink_count = block._sink_count + 1
- Port.__init__(self, block, n)
+ return self.__class__(self.get_parent(), n, self._dir)
$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()
+ #end if
+ ####################################################################
+ ## Logic to extract source and sink names
+ ####################################################################
#if $source.get_parent().get_key() == 'pad_source'
#set $source_name = 'self'
#else
#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()))
+ #end if
#end for
########################################################
##################################################
# Problems
##################################################
+* need a way to make an id param in the xml that will override the default
+ * ex: display pad sink id in continuation mode using hide tag for id param
* hier block generation
* auto generate hier library on changes
* auto clean hier library when block removed