summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/python/gnuradio/eng_option.py22
-rw-r--r--gr-wxgui/src/python/constants.py2
-rw-r--r--gr-wxgui/src/python/fft_window.py78
-rw-r--r--grc/Makefile.inc4
-rw-r--r--grc/base/Block.py8
-rw-r--r--grc/base/Platform.py3
-rw-r--r--grc/base/Port.py20
-rw-r--r--grc/blocks/options.xml1
-rw-r--r--grc/blocks/pad_sink.xml21
-rw-r--r--grc/blocks/pad_source.xml31
-rw-r--r--grc/blocks/parameter.xml9
-rw-r--r--grc/gui/ActionHandler.py6
-rw-r--r--grc/gui/Actions.py4
-rw-r--r--grc/gui/Bars.py2
-rw-r--r--grc/gui/Dialogs.py4
-rw-r--r--grc/gui/Platform.py5
-rw-r--r--grc/gui/Port.py2
-rw-r--r--grc/python/Platform.py5
-rw-r--r--grc/python/Port.py34
-rw-r--r--grc/python/flow_graph.tmpl39
-rw-r--r--grc/todo.txt5
21 files changed, 201 insertions, 104 deletions
diff --git a/gnuradio-core/src/python/gnuradio/eng_option.py b/gnuradio-core/src/python/gnuradio/eng_option.py
index 09c3e1d87..e10235f14 100644
--- a/gnuradio-core/src/python/gnuradio/eng_option.py
+++ b/gnuradio-core/src/python/gnuradio/eng_option.py
@@ -23,29 +23,11 @@
from copy import copy
from optparse import Option, OptionValueError
-
-scale_factor = {}
-scale_factor['E'] = 1e18
-scale_factor['P'] = 1e15
-scale_factor['T'] = 1e12
-scale_factor['G'] = 1e9
-scale_factor['M'] = 1e6
-scale_factor['k'] = 1e3
-scale_factor['m'] = 1e-3
-scale_factor['u'] = 1e-6
-scale_factor['n'] = 1e-9
-scale_factor['p'] = 1e-12
-scale_factor['f'] = 1e-15
-scale_factor['a'] = 1e-18
-
+import eng_notation
def check_eng_float (option, opt, value):
try:
- scale = 1.0
- suffix = value[-1]
- if scale_factor.has_key (suffix):
- return float (value[0:-1]) * scale_factor[suffix]
- return float (value)
+ return eng_notation.str_to_num(value)
except:
raise OptionValueError (
"option %s: invalid engineering notation value: %r" % (opt, value))
diff --git a/gr-wxgui/src/python/constants.py b/gr-wxgui/src/python/constants.py
index 5e1395701..8ff7fa8fe 100644
--- a/gr-wxgui/src/python/constants.py
+++ b/gr-wxgui/src/python/constants.py
@@ -41,6 +41,8 @@ MSG_KEY = 'msg'
NUM_LINES_KEY = 'num_lines'
OMEGA_KEY = 'omega'
PEAK_HOLD_KEY = 'peak_hold'
+TRACE_STORE_KEY = 'trace_store'
+TRACE_SHOW_KEY = 'trace_show'
REF_LEVEL_KEY = 'ref_level'
RUNNING_KEY = 'running'
SAMPLE_RATE_KEY = 'sample_rate'
diff --git a/gr-wxgui/src/python/fft_window.py b/gr-wxgui/src/python/fft_window.py
index ba5711d10..0529e6a5d 100644
--- a/gr-wxgui/src/python/fft_window.py
+++ b/gr-wxgui/src/python/fft_window.py
@@ -39,10 +39,15 @@ SLIDER_STEPS = 100
AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0
DEFAULT_WIN_SIZE = (600, 300)
DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'fft_rate', 30)
-DIV_LEVELS = (1, 2, 5, 10, 20)
+DB_DIV_MIN, DB_DIV_MAX = 1, 20
FFT_PLOT_COLOR_SPEC = (0.3, 0.3, 1.0)
PEAK_VALS_COLOR_SPEC = (0.0, 0.8, 0.0)
-NO_PEAK_VALS = list()
+EMPTY_TRACE = list()
+TRACES = ('A', 'B')
+TRACES_COLOR_SPEC = {
+ 'A': (1.0, 0.0, 0.0),
+ 'B': (0.8, 0.0, 0.8),
+}
##################################################
# FFT window control panel
@@ -63,7 +68,7 @@ class control_panel(wx.Panel):
control_box.AddStretchSpacer()
#checkboxes for average and peak hold
options_box = forms.static_box_sizer(
- parent=self, sizer=control_box, label='Options',
+ parent=self, sizer=control_box, label='Trace Options',
bold=True, orient=wx.VERTICAL,
)
forms.check_box(
@@ -90,17 +95,32 @@ class control_panel(wx.Panel):
for widget in (avg_alpha_text, avg_alpha_slider):
parent.subscribe(AVERAGE_KEY, widget.Enable)
widget.Enable(parent[AVERAGE_KEY])
+
+ #trace menu
+ for trace in TRACES:
+ trace_box = wx.BoxSizer(wx.HORIZONTAL)
+ options_box.Add(trace_box, 0, wx.EXPAND)
+ forms.check_box(
+ sizer=trace_box, parent=self,
+ ps=parent, key=TRACE_SHOW_KEY+trace,
+ label='Trace %s'%trace,
+ )
+ trace_box.AddSpacer(10)
+ forms.single_button(
+ sizer=trace_box, parent=self,
+ ps=parent, key=TRACE_STORE_KEY+trace,
+ label='Store', style=wx.BU_EXACTFIT,
+ )
+ trace_box.AddSpacer(10)
#radio buttons for div size
control_box.AddStretchSpacer()
y_ctrl_box = forms.static_box_sizer(
parent=self, sizer=control_box, label='Axis Options',
bold=True, orient=wx.VERTICAL,
)
- forms.radio_buttons(
- sizer=y_ctrl_box, parent=self,
- ps=parent, key=Y_PER_DIV_KEY,
- style=wx.RA_VERTICAL|wx.NO_BORDER, choices=DIV_LEVELS,
- labels=map(lambda x: '%s dB/div'%x, DIV_LEVELS),
+ forms.incr_decr_buttons(
+ parent=self, sizer=y_ctrl_box, label='dB/Div',
+ on_incr=self._on_incr_db_div, on_decr=self._on_decr_db_div,
)
#ref lvl buttons
forms.incr_decr_buttons(
@@ -135,6 +155,10 @@ class control_panel(wx.Panel):
self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] + self.parent[Y_PER_DIV_KEY]
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)
+ def _on_decr_db_div(self, event):
+ self.parent[Y_PER_DIV_KEY] = max(DB_DIV_MIN, self.parent[Y_PER_DIV_KEY]/2)
##################################################
# FFT window with plotter and control panel
@@ -159,13 +183,12 @@ class fft_window(wx.Panel, pubsub.pubsub):
msg_key,
):
pubsub.pubsub.__init__(self)
- #ensure y_per_div
- if y_per_div not in DIV_LEVELS: y_per_div = DIV_LEVELS[0]
#setup
- self.samples = list()
+ self.samples = EMPTY_TRACE
self.real = real
self.fft_size = fft_size
self._reset_peak_vals()
+ self._traces = dict()
#proxy the keys
self.proxy(MSG_KEY, controller, msg_key)
self.proxy(AVERAGE_KEY, controller, average_key)
@@ -179,6 +202,26 @@ class fft_window(wx.Panel, pubsub.pubsub):
self[REF_LEVEL_KEY] = ref_level
self[BASEBAND_FREQ_KEY] = baseband_freq
self[RUNNING_KEY] = True
+ for trace in TRACES:
+ #a function that returns a function
+ #so the function wont use local trace
+ def new_store_trace(my_trace):
+ def store_trace(*args):
+ self._traces[my_trace] = self.samples
+ self.update_grid()
+ return store_trace
+ def new_toggle_trace(my_trace):
+ def toggle_trace(toggle):
+ #do an automatic store if toggled on and empty trace
+ if toggle and not len(self._traces[my_trace]):
+ self._traces[my_trace] = self.samples
+ self.update_grid()
+ return toggle_trace
+ self._traces[trace] = EMPTY_TRACE
+ self[TRACE_STORE_KEY+trace] = False
+ self[TRACE_SHOW_KEY+trace] = False
+ self.subscribe(TRACE_STORE_KEY+trace, new_store_trace(trace))
+ self.subscribe(TRACE_SHOW_KEY+trace, new_toggle_trace(trace))
#init panel and plot
wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
self.plotter = plotter.channel_plotter(self)
@@ -194,7 +237,7 @@ class fft_window(wx.Panel, pubsub.pubsub):
main_box.Add(self.control_panel, 0, wx.EXPAND)
self.SetSizerAndFit(main_box)
#register events
- self.subscribe(AVERAGE_KEY, lambda x: self._reset_peak_vals())
+ self.subscribe(AVERAGE_KEY, self._reset_peak_vals)
self.subscribe(MSG_KEY, self.handle_msg)
self.subscribe(SAMPLE_RATE_KEY, self.update_grid)
for key in (
@@ -223,7 +266,7 @@ class fft_window(wx.Panel, pubsub.pubsub):
#set the range to a clean number of the dynamic range
self[Y_PER_DIV_KEY] = common.get_clean_num((peak_level - noise_floor)/self[Y_DIVS_KEY])
- def _reset_peak_vals(self): self.peak_vals = NO_PEAK_VALS
+ def _reset_peak_vals(self, *args): self.peak_vals = EMPTY_TRACE
def handle_msg(self, msg):
"""
@@ -272,6 +315,15 @@ class fft_window(wx.Panel, pubsub.pubsub):
The x axis depends on sample rate, baseband freq, and x divs.
The y axis depends on y per div, y divs, and ref level.
"""
+ for trace in TRACES:
+ channel = '%s'%trace.upper()
+ if self[TRACE_SHOW_KEY+trace]:
+ self.plotter.set_waveform(
+ channel=channel,
+ samples=self._traces[trace],
+ color_spec=TRACES_COLOR_SPEC[trace],
+ )
+ else: self.plotter.clear_waveform(channel=channel)
#grid parameters
sample_rate = self[SAMPLE_RATE_KEY]
baseband_freq = self[BASEBAND_FREQ_KEY]
diff --git a/grc/Makefile.inc b/grc/Makefile.inc
index 96ee11b67..c45d1ce1f 100644
--- a/grc/Makefile.inc
+++ b/grc/Makefile.inc
@@ -1,5 +1,5 @@
#
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008, 2009 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,5 +20,5 @@
#
include $(top_srcdir)/Makefile.common
-grc_src_prefix = $(pythondir)/gnuradio/grc
+grc_src_prefix = $(pkgpythondir)/grc
grc_blocksdir = $(pkgdatadir)/grc/blocks
diff --git a/grc/base/Block.py b/grc/base/Block.py
index d5e104785..349e71f76 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -47,7 +47,9 @@ class TemplateArg(UserDict):
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):
@@ -98,7 +100,7 @@ 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()
@@ -107,7 +109,7 @@ class Block(Element):
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()
diff --git a/grc/base/Platform.py b/grc/base/Platform.py
index 02d6d2319..db7ade9a3 100644
--- a/grc/base/Platform.py
+++ b/grc/base/Platform.py
@@ -171,6 +171,5 @@ class Platform(_Element):
FlowGraph = _FlowGraph
Connection = _Connection
Block = _Block
- Source = _Port
- Sink = _Port
+ Port = _Port
Param = _Param
diff --git a/grc/base/Port.py b/grc/base/Port.py
index f4e8e5e1f..8e60d5093 100644
--- a/grc/base/Port.py
+++ b/grc/base/Port.py
@@ -24,22 +24,20 @@ class Port(Element):
##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):
"""
@@ -60,8 +58,8 @@ class Port(Element):
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):
diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml
index 18d6e2f0c..a28a0b143 100644
--- a/grc/blocks/options.xml
+++ b/grc/blocks/options.xml
@@ -17,6 +17,7 @@ import wx
#if $generate_options() != 'hb'
from optparse import OptionParser
from gnuradio.eng_option import eng_option
+from gnuradio import eng_notation
#end if
</import>
<make></make>
diff --git a/grc/blocks/pad_sink.xml b/grc/blocks/pad_sink.xml
index 477f2ad13..999de315d 100644
--- a/grc/blocks/pad_sink.xml
+++ b/grc/blocks/pad_sink.xml
@@ -9,6 +9,20 @@
<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>
<value>1</value>
@@ -59,10 +73,11 @@
<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>
diff --git a/grc/blocks/pad_source.xml b/grc/blocks/pad_source.xml
index b6ef2c55d..26491adb3 100644
--- a/grc/blocks/pad_source.xml
+++ b/grc/blocks/pad_source.xml
@@ -9,6 +9,20 @@
<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>
@@ -50,6 +64,13 @@
<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 &gt; 0</check>
<check>0 &lt; $nports</check>
<source>
@@ -59,10 +80,12 @@
<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>
diff --git a/grc/blocks/parameter.xml b/grc/blocks/parameter.xml
index 5d08c4b39..e35b8f4d1 100644
--- a/grc/blocks/parameter.xml
+++ b/grc/blocks/parameter.xml
@@ -45,7 +45,7 @@
</option>
<option>
<name>Int</name>
- <key>int</key>
+ <key>intx</key>
<opt>type:int</opt>
</option>
<option>
@@ -58,6 +58,13 @@
<key>string</key>
<opt>type:string</opt>
</option>
+ <!-- not supported yet in tmpl
+ <option>
+ <name>Boolean</name>
+ <key>bool</key>
+ <opt>type:bool</opt>
+ </option>
+ -->
</param>
<param>
<name>Short ID</name>
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index ff137f669..9af580e8e 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -133,7 +133,7 @@ class ActionHandler:
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()
@@ -237,8 +237,8 @@ class ActionHandler:
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
##################################################
diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py
index 3695e09ef..c3ef2711a 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -57,7 +57,7 @@ FLOW_GRAPH_KILL = 'flow graph kill'
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
@@ -132,7 +132,7 @@ _actions_list = (
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),
diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py
index e0c547eba..697d48a3c 100644
--- a/grc/gui/Bars.py
+++ b/grc/gui/Bars.py
@@ -88,7 +88,7 @@ MENU_BAR_LIST = (
]),
(gtk.Action('Help', '_Help', None, None), [
Actions.HELP_WINDOW_DISPLAY,
- Actions.COLORS_WINDOW_DISPLAY,
+ Actions.TYPES_WINDOW_DISPLAY,
None,
Actions.ABOUT_WINDOW_DISPLAY,
]),
diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py
index 8d764e28e..3cf617b92 100644
--- a/grc/gui/Dialogs.py
+++ b/grc/gui/Dialogs.py
@@ -98,8 +98,8 @@ COLORS_DIALOG_MARKUP_TMPL = """\
#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()))
diff --git a/grc/gui/Platform.py b/grc/gui/Platform.py
index a32b0209f..1530a69d6 100644
--- a/grc/gui/Platform.py
+++ b/grc/gui/Platform.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
@@ -38,8 +38,7 @@ def Platform(platform):
('FlowGraph', FlowGraph),
('Connection', Connection),
('Block', Block),
- ('Source', Port),
- ('Sink', Port),
+ ('Port', Port),
('Param', Param),
):
old_value = getattr(platform, attr)
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index d1f36f8b9..6fc2c4b15 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -1,5 +1,5 @@
"""
-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
diff --git a/grc/python/Platform.py b/grc/python/Platform.py
index d55dbf4ce..cab25d348 100644
--- a/grc/python/Platform.py
+++ b/grc/python/Platform.py
@@ -23,7 +23,7 @@ from .. base.Platform import Platform as _Platform
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 \
@@ -77,6 +77,5 @@ class Platform(_Platform):
FlowGraph = _FlowGraph
Connection = _Connection
Block = _Block
- Source = Source
- Sink = Sink
+ Port = _Port
Param = _Param
diff --git a/grc/python/Port.py b/grc/python/Port.py
index daf8f9ca3..f71c5fa35 100644
--- a/grc/python/Port.py
+++ b/grc/python/Port.py
@@ -25,17 +25,27 @@ class Port(_Port):
##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 ''
@@ -109,24 +119,4 @@ class Port(_Port):
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)
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index df346dd16..924a280c4 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -161,8 +161,20 @@ class $(class_name)(gr.hier_block2):
$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
@@ -173,7 +185,12 @@ class $(class_name)(gr.hier_block2):
#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
########################################################
@@ -194,6 +211,20 @@ class $(class_name)(gr.hier_block2):
## For top block code, generate a main routine.
## Instantiate the top block and run as gui or cli.
########################################################
+#def make_default($type, $param)
+ #if $type == 'eng_float'
+eng_notation.num_to_str($param.get_make())#slurp
+ #else
+$param.get_make()#slurp
+ #end if
+#end def
+#def make_short_id($param)
+ #set $short_id = $param.get_param('short_id').get_evaluated()
+ #if $short_id
+ #set $short_id = '-' + $short_id
+ #end if
+$short_id#slurp
+#end def
#if $generate_options != 'hb'
if __name__ == '__main__':
parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
@@ -202,12 +233,8 @@ if __name__ == '__main__':
#set $type = $param.get_param('type').get_value()
#if $type
#silent $params_eq_list.append('%s=options.%s'%($param.get_id(), $param.get_id()))
- #set $short_id = $param.get_param('short_id').get_evaluated()
- #if $short_id
- #set $short_id = '-' + $short_id
- #end if
- parser.add_option("$short_id", "--$param.get_id()", dest="$param.get_id()", type="$type", default=$param.get_make(),
- help="Set $($param.get_param('label').evaluate() or $param.get_id()) [default=%default]")
+ parser.add_option("$make_short_id($param)", "--$param.get_id().replace('_', '-')", dest="$param.get_id()", type="$type", default=$make_default($type, $param),
+ help="Set $($param.get_param('label').get_evaluated() or $param.get_id()) [default=%default]")
#end if
#end for
(options, args) = parser.parse_args()
diff --git a/grc/todo.txt b/grc/todo.txt
index bb40e1f16..ad02bf790 100644
--- a/grc/todo.txt
+++ b/grc/todo.txt
@@ -25,8 +25,7 @@
* size params for the graphical sinks
* callbacks for set average on fft, waterfall, number sinks
* add units to params: Sps, Hz, dB...
-* command line options should replace _ with - for the --option
- * add bool type to command line option store_true or store_false
+* add bool type to command line option store_true or store_false
##################################################
# Features
@@ -59,6 +58,8 @@
##################################################
# 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