summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Blum2009-08-28 18:15:49 -0700
committerJosh Blum2009-08-28 18:15:49 -0700
commitcadc9548afb7b4a385cea51f48745f0a1c702607 (patch)
treed5f14ba1cf7f680ce81f28a569ba6eb7ec1c6ca6
parent36d1520f0ac73b64bd0541b422552a6d419c7ffd (diff)
downloadgnuradio-cadc9548afb7b4a385cea51f48745f0a1c702607.tar.gz
gnuradio-cadc9548afb7b4a385cea51f48745f0a1c702607.tar.bz2
gnuradio-cadc9548afb7b4a385cea51f48745f0a1c702607.zip
Recursive resolution of virtual sources.
Flow graph generation code working. Also, mod to fft window to use clean/nice Db/div.
-rw-r--r--gr-wxgui/src/python/fft_window.py6
-rw-r--r--grc/python/Connection.py2
-rw-r--r--grc/python/Port.py45
-rw-r--r--grc/python/flow_graph.tmpl7
4 files changed, 41 insertions, 19 deletions
diff --git a/gr-wxgui/src/python/fft_window.py b/gr-wxgui/src/python/fft_window.py
index 0529e6a5d..926812d8c 100644
--- a/gr-wxgui/src/python/fft_window.py
+++ b/gr-wxgui/src/python/fft_window.py
@@ -1,5 +1,5 @@
#
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008, 2009 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -156,9 +156,9 @@ class control_panel(wx.Panel):
def _on_decr_ref_level(self, event):
self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] - self.parent[Y_PER_DIV_KEY]
def _on_incr_db_div(self, event):
- self.parent[Y_PER_DIV_KEY] = min(DB_DIV_MAX, self.parent[Y_PER_DIV_KEY]*2)
+ self.parent[Y_PER_DIV_KEY] = min(DB_DIV_MAX, common.get_clean_incr(self.parent[Y_PER_DIV_KEY]))
def _on_decr_db_div(self, event):
- self.parent[Y_PER_DIV_KEY] = max(DB_DIV_MIN, self.parent[Y_PER_DIV_KEY]/2)
+ self.parent[Y_PER_DIV_KEY] = max(DB_DIV_MIN, common.get_clean_decr(self.parent[Y_PER_DIV_KEY]))
##################################################
# FFT window with plotter and control panel
diff --git a/grc/python/Connection.py b/grc/python/Connection.py
index 5eba9f24d..85b5b2c52 100644
--- a/grc/python/Connection.py
+++ b/grc/python/Connection.py
@@ -1,5 +1,5 @@
"""
-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
diff --git a/grc/python/Port.py b/grc/python/Port.py
index b386e3f89..2f7af855c 100644
--- a/grc/python/Port.py
+++ b/grc/python/Port.py
@@ -20,6 +20,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from .. base.Port import Port as _Port
import Constants
+def _get_source_from_virtual_sink_port(vsp):
+ try: return _get_source_from_virtual_source_port(
+ vsp.get_enabled_connections()[0].get_source())
+ except: raise Exception, 'Could not resolve source for virtual sink port', vsp
+
+def _get_source_from_virtual_source_port(vsp):
+ if not vsp.is_virtual_source(): return vsp
+ try: return _get_source_from_virtual_source_port(
+ _get_source_from_virtual_sink_port(
+ filter(
+ lambda vs: vs.get_param('stream_id').get_value() == vsp.get_parent().get_param('stream_id').get_value(),
+ filter(
+ lambda b: b.get_key() == 'virtual_sink',
+ vsp.get_parent().get_parent().get_enabled_blocks(),
+ ),
+ )[0].get_sink(vsp.get_key())
+ )
+ )
+ except: raise Exception, 'Could not resolve source for virtual source port', vsp
+
class Port(_Port):
##possible port types
@@ -69,26 +89,21 @@ class Port(_Port):
Handle the port cloning for virtual blocks.
"""
_Port.rewrite(self)
- if self.get_parent().get_key() in ('virtual_sink', 'virtual_source'):
- try:
- if self.get_parent().get_key() == 'virtual_sink':
- source = self.get_enabled_connections()[0].get_source()
- if self.get_parent().get_key() == 'virtual_source':
- source = filter(
- lambda vs: vs.get_param('stream_id').get_value() == self.get_parent().get_param('stream_id').get_value(),
- filter(
- lambda b: b.get_key() == 'virtual_sink',
- self.get_parent().get_parent().get_enabled_blocks(),
- ),
- )[0].get_sink('0').get_enabled_connections()[0].get_source()
- #clone type and vlen
+ if self.is_virtual_sink() or self.is_virtual_source():
+ try: #clone type and vlen
+ source = self.resolve_virtual_source()
self._type = str(source.get_type())
self._vlen = str(source.get_vlen())
- except:
- #reset type and vlen
+ except: #reset type and vlen
self._type = ''
self._vlen = ''
+ def is_virtual_sink(self): return self.get_parent().get_key() == 'virtual_sink'
+ def is_virtual_source(self): return self.get_parent().get_key() == 'virtual_source'
+ def resolve_virtual_source(self):
+ if self.is_virtual_sink(): return _get_source_from_virtual_sink_port(self)
+ if self.is_virtual_source(): return _get_source_from_virtual_source_port(self)
+
def get_vlen(self):
"""
Get the vector length.
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index 5e5844052..bd12e82e9 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -170,7 +170,14 @@ self.$port.get_parent().get_id()#slurp
#for $con in $connections
#set $source = $con.get_source()
#set $sink = $con.get_sink()
+ ##resolve virtual sources to the actual sources
+ #if $source.is_virtual_source()
+ #set $source = $source.resolve_virtual_source()
+ #end if
+ ##do not generate connections with virtual sinks
+ #if not $sink.is_virtual_sink()
self.connect(($make_port_name($source), $source.get_key()), ($make_port_name($sink), $sink.get_key()))
+ #end if
#end for
########################################################