From: Josh Blum Date: Tue, 25 Aug 2009 04:35:46 +0000 (-0700) Subject: Merge branch 'wxgui' of git@gnuradio.org:jblum into grc X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e6f9073f11e016fba2793c3a6d9c026399994e08;hp=b6c19491d34357ab2d6332f91733afe7367da92a;p=debian%2Fgnuradio Merge branch 'wxgui' of git@gnuradio.org:jblum into grc --- diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py index b1b3dfca..e40d9636 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py @@ -24,7 +24,7 @@ from gnuradio import gr class pfb_arb_resampler_ccf(gr.hier_block2): ''' - Convinience wrapper for the polyphase filterbank arbitrary resampler. + Convenience wrapper for the polyphase filterbank arbitrary resampler. The block takes a single complex stream in and outputs a single complex stream out. As such, it requires no extra glue to handle the input/output @@ -45,6 +45,5 @@ class pfb_arb_resampler_ccf(gr.hier_block2): self.connect(self, self.pfb) self.connect(self.pfb, self) - - - + def set_taps(self, taps): + self.pfb.set_taps(taps) diff --git a/gnuradio-examples/python/pfb/Makefile.am b/gnuradio-examples/python/pfb/Makefile.am index 4aa9248e..0b91d0a2 100644 --- a/gnuradio-examples/python/pfb/Makefile.am +++ b/gnuradio-examples/python/pfb/Makefile.am @@ -29,3 +29,6 @@ dist_ourdata_SCRIPTS = \ decimate.py \ interpolate.py \ fmtest.py + +dist_ourdata_DATA = \ + resampler_demo.grc diff --git a/gnuradio-examples/python/pfb/resampler_demo.grc b/gnuradio-examples/python/pfb/resampler_demo.grc new file mode 100644 index 00000000..468636a5 --- /dev/null +++ b/gnuradio-examples/python/pfb/resampler_demo.grc @@ -0,0 +1,598 @@ + + + Sun Aug 23 11:39:47 2009 + + options + + id + resampler_demo + + + _enabled + True + + + title + + + + author + + + + description + + + + window_size + 1280, 1024 + + + generate_options + wx_gui + + + category + Custom + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + import + + id + import_0 + + + _enabled + True + + + import + import math + + + _coordinate + (11, 59) + + + _rotation + 0 + + + + variable + + id + rs_taps + + + _enabled + True + + + value + firdes.low_pass(nphases, nphases, frac_bw, 0.5-frac_bw) + + + _coordinate + (273, 154) + + + _rotation + 0 + + + + gr_add_const_vxx + + id + adder + + + _enabled + True + + + type + float + + + const + -1.0 + + + vlen + 1 + + + _coordinate + (227, 303) + + + _rotation + 0 + + + + gr_throttle + + id + throttle + + + _enabled + True + + + type + float + + + samples_per_second + samp_rate + + + vlen + 1 + + + _coordinate + (227, 493) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + orig_fft + + + _enabled + True + + + type + complex + + + title + Original Spectrum + + + samp_rate + samp_rate + + + baseband_freq + 0 + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 30 + + + fft_size + 1024 + + + fft_rate + 30 + + + peak_hold + False + + + average + False + + + avg_alpha + 0 + + + grid_pos + 1, 0, 1, 3 + + + notebook + + + + _coordinate + (409, 289) + + + _rotation + 180 + + + + wxgui_fftsink2 + + id + resamp_fft + + + _enabled + True + + + type + complex + + + title + Resampled Spectrum + + + samp_rate + new_rate + + + baseband_freq + 0 + + + y_per_div + 10 + + + y_divs + 10 + + + ref_level + 30 + + + fft_size + 1024 + + + fft_rate + 30 + + + peak_hold + True + + + average + False + + + avg_alpha + 0 + + + grid_pos + 2, 0, 1, 3 + + + notebook + + + + _coordinate + (640, 256) + + + _rotation + 180 + + + + gr_sig_source_x + + id + tri_source + + + _enabled + True + + + type + float + + + samp_rate + samp_rate + + + waveform + gr.GR_TRI_WAVE + + + freq + 0.05 + + + amp + 2.0 + + + offset + 0 + + + _coordinate + (21, 271) + + + _rotation + 0 + + + + gr_frequency_modulator_fc + + id + fm_mod + + + _enabled + True + + + sensitivity + math.pi + + + _coordinate + (411, 493) + + + _rotation + 0 + + + + blks2_pfb_arb_resampler_ccf + + id + resampler + + + _enabled + True + + + rate + float(new_rate)/samp_rate + + + taps + rs_taps + + + size + nphases + + + _coordinate + (641, 477) + + + _rotation + 0 + + + + variable + + id + nphases + + + _enabled + True + + + value + 32 + + + _coordinate + (185, 153) + + + _rotation + 0 + + + + variable_static_text + + id + samp_rate + + + _enabled + True + + + label + Sample Rate + + + value + 44100 + + + converver + float_converter + + + formatter + None + + + grid_pos + 0, 0, 1, 1 + + + notebook + + + + _coordinate + (179, 14) + + + _rotation + 0 + + + + variable_static_text + + id + new_rate + + + _enabled + True + + + label + Resampled Rate + + + value + 48000 + + + converver + float_converter + + + formatter + None + + + grid_pos + 0, 1, 1, 1 + + + notebook + + + + _coordinate + (328, 15) + + + _rotation + 0 + + + + variable_static_text + + id + frac_bw + + + _enabled + True + + + label + Fractional Bandwidth + + + value + 0.45 + + + converver + float_converter + + + formatter + lambda x: "%0.2f"%x + + + grid_pos + 0,2,1,1 + + + notebook + + + + _coordinate + (473, 14) + + + _rotation + 0 + + + + tri_source + adder + 0 + 0 + + + adder + throttle + 0 + 0 + + + resampler + resamp_fft + 0 + 0 + + + fm_mod + resampler + 0 + 0 + + + fm_mod + orig_fft + 0 + 0 + + + throttle + fm_mod + 0 + 0 + + diff --git a/grc/Makefile.inc b/grc/Makefile.inc index 96ee11b6..c45d1ce1 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 d5e10478..349e71f7 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 02d6d231..db7ade9a 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 f4e8e5e1..8e60d509 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/Makefile.am b/grc/blocks/Makefile.am index fbd8f4bb..caae6ce7 100644 --- a/grc/blocks/Makefile.am +++ b/grc/blocks/Makefile.am @@ -45,6 +45,7 @@ dist_ourdata_DATA = \ blks2_ofdm_mod.xml \ blks2_packet_decoder.xml \ blks2_packet_encoder.xml \ + blks2_pfb_arb_resampler.xml \ blks2_qamx_demod.xml \ blks2_qamx_mod.xml \ blks2_rational_resampler_xxx.xml \ diff --git a/grc/blocks/blks2_pfb_arb_resampler.xml b/grc/blocks/blks2_pfb_arb_resampler.xml new file mode 100644 index 00000000..062b0dd9 --- /dev/null +++ b/grc/blocks/blks2_pfb_arb_resampler.xml @@ -0,0 +1,42 @@ + + + + Polyphase Resampler + blks2_pfb_arb_resampler_ccf + from gnuradio import blks2 + from gnuradio.gr import firdes + blks2.pfb_arb_resampler_ccf( + $rate, + $taps, + $size, +) + set_taps($taps) + + Resample Rate + rate + real + + + Taps + taps + real_vector + + + Size (# phases) + size + 32 + int + + + in + complex + + + out + complex + + diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index 2cedb45a..5b45466f 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -176,6 +176,8 @@ blks2_synthesis_filterbank blks2_analysis_filterbank + + blks2_pfb_arb_resampler_ccf gr_single_pole_iir_filter_xx gr_hilbert_fc diff --git a/grc/blocks/pad_sink.xml b/grc/blocks/pad_sink.xml index 477f2ad1..999de315 100644 --- a/grc/blocks/pad_sink.xml +++ b/grc/blocks/pad_sink.xml @@ -8,6 +8,20 @@ Pad Sink pad_sink + + Mode + mode + hb + enum + + + Num Inputs nports @@ -59,10 +73,11 @@ $nports -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. diff --git a/grc/blocks/pad_source.xml b/grc/blocks/pad_source.xml index b6ef2c55..26491adb 100644 --- a/grc/blocks/pad_source.xml +++ b/grc/blocks/pad_source.xml @@ -8,6 +8,20 @@ Pad Source pad_source + + Mode + mode + hb + enum + + + Num Outputs nports @@ -50,6 +64,13 @@ 1 int + + Pad Sink ID + pad_sink_id + pad_sink_0 + string + #if $mode() == 'cont' then 'none' else 'all'# + $vlen > 0 0 < $nports @@ -59,10 +80,12 @@ $nports -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. diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index ff137f66..9af580e8 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 3695e09e..c3ef2711 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 e0c547eb..697d48a3 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 8d764e28..3cf617b9 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 a32b0209..1530a69d 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 d1f36f8b..6fc2c4b1 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 d55dbf4c..cab25d34 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 daf8f9ca..f71c5fa3 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 df346dd1..32139636 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 ######################################################## diff --git a/grc/todo.txt b/grc/todo.txt index bb40e1f1..577e4c33 100644 --- a/grc/todo.txt +++ b/grc/todo.txt @@ -59,6 +59,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