diff options
-rw-r--r-- | gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py | 7 | ||||
-rw-r--r-- | gnuradio-examples/python/pfb/Makefile.am | 3 | ||||
-rw-r--r-- | gnuradio-examples/python/pfb/resampler_demo.grc | 598 | ||||
-rw-r--r-- | grc/Makefile.inc | 4 | ||||
-rw-r--r-- | grc/base/Block.py | 8 | ||||
-rw-r--r-- | grc/base/Platform.py | 3 | ||||
-rw-r--r-- | grc/base/Port.py | 20 | ||||
-rw-r--r-- | grc/blocks/Makefile.am | 1 | ||||
-rw-r--r-- | grc/blocks/blks2_pfb_arb_resampler.xml | 42 | ||||
-rw-r--r-- | grc/blocks/block_tree.xml | 2 | ||||
-rw-r--r-- | grc/blocks/pad_sink.xml | 21 | ||||
-rw-r--r-- | grc/blocks/pad_source.xml | 31 | ||||
-rw-r--r-- | grc/gui/ActionHandler.py | 6 | ||||
-rw-r--r-- | grc/gui/Actions.py | 4 | ||||
-rw-r--r-- | grc/gui/Bars.py | 2 | ||||
-rw-r--r-- | grc/gui/Dialogs.py | 4 | ||||
-rw-r--r-- | grc/gui/Platform.py | 5 | ||||
-rw-r--r-- | grc/gui/Port.py | 2 | ||||
-rw-r--r-- | grc/python/Platform.py | 5 | ||||
-rw-r--r-- | grc/python/Port.py | 34 | ||||
-rw-r--r-- | grc/python/flow_graph.tmpl | 17 | ||||
-rw-r--r-- | grc/todo.txt | 2 |
22 files changed, 755 insertions, 66 deletions
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 b1b3dfcab..e40d9636a 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 4aa9248ea..0b91d0a2d 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 000000000..468636a5c --- /dev/null +++ b/gnuradio-examples/python/pfb/resampler_demo.grc @@ -0,0 +1,598 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Sun Aug 23 11:39:47 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>resampler_demo</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value></value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>import math</value> + </param> + <param> + <key>_coordinate</key> + <value>(11, 59)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>rs_taps</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>firdes.low_pass(nphases, nphases, frac_bw, 0.5-frac_bw)</value> + </param> + <param> + <key>_coordinate</key> + <value>(273, 154)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_add_const_vxx</key> + <param> + <key>id</key> + <value>adder</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>const</key> + <value>-1.0</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(227, 303)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_throttle</key> + <param> + <key>id</key> + <value>throttle</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>samples_per_second</key> + <value>samp_rate</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(227, 493)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>orig_fft</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Original Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>0</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>10</value> + </param> + <param> + <key>ref_level</key> + <value>30</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>30</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>grid_pos</key> + <value>1, 0, 1, 3</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(409, 289)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>resamp_fft</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Resampled Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>new_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>0</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>10</value> + </param> + <param> + <key>ref_level</key> + <value>30</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>30</value> + </param> + <param> + <key>peak_hold</key> + <value>True</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>grid_pos</key> + <value>2, 0, 1, 3</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(640, 256)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>gr_sig_source_x</key> + <param> + <key>id</key> + <value>tri_source</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>waveform</key> + <value>gr.GR_TRI_WAVE</value> + </param> + <param> + <key>freq</key> + <value>0.05</value> + </param> + <param> + <key>amp</key> + <value>2.0</value> + </param> + <param> + <key>offset</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(21, 271)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_frequency_modulator_fc</key> + <param> + <key>id</key> + <value>fm_mod</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>sensitivity</key> + <value>math.pi</value> + </param> + <param> + <key>_coordinate</key> + <value>(411, 493)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blks2_pfb_arb_resampler_ccf</key> + <param> + <key>id</key> + <value>resampler</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>rate</key> + <value>float(new_rate)/samp_rate</value> + </param> + <param> + <key>taps</key> + <value>rs_taps</value> + </param> + <param> + <key>size</key> + <value>nphases</value> + </param> + <param> + <key>_coordinate</key> + <value>(641, 477)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>nphases</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>32</value> + </param> + <param> + <key>_coordinate</key> + <value>(185, 153)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_static_text</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Sample Rate</value> + </param> + <param> + <key>value</key> + <value>44100</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>formatter</key> + <value>None</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 0, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(179, 14)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_static_text</key> + <param> + <key>id</key> + <value>new_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Resampled Rate</value> + </param> + <param> + <key>value</key> + <value>48000</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>formatter</key> + <value>None</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 1, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(328, 15)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_static_text</key> + <param> + <key>id</key> + <value>frac_bw</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Fractional Bandwidth</value> + </param> + <param> + <key>value</key> + <value>0.45</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>formatter</key> + <value>lambda x: "%0.2f"%x</value> + </param> + <param> + <key>grid_pos</key> + <value>0,2,1,1</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(473, 14)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>tri_source</source_block_id> + <sink_block_id>adder</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>adder</source_block_id> + <sink_block_id>throttle</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>resampler</source_block_id> + <sink_block_id>resamp_fft</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>fm_mod</source_block_id> + <sink_block_id>resampler</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>fm_mod</source_block_id> + <sink_block_id>orig_fft</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>throttle</source_block_id> + <sink_block_id>fm_mod</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> 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/Makefile.am b/grc/blocks/Makefile.am index fbd8f4bb4..caae6ce75 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 000000000..062b0dd98 --- /dev/null +++ b/grc/blocks/blks2_pfb_arb_resampler.xml @@ -0,0 +1,42 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Polyphase Arbitrary Resampler +################################################### + --> +<block> + <name>Polyphase Resampler</name> + <key>blks2_pfb_arb_resampler_ccf</key> + <import>from gnuradio import blks2</import> + <import>from gnuradio.gr import firdes</import> + <make>blks2.pfb_arb_resampler_ccf( + $rate, + $taps, + $size, +)</make> + <callback>set_taps($taps)</callback> + <param> + <name>Resample Rate</name> + <key>rate</key> + <type>real</type> + </param> + <param> + <name>Taps</name> + <key>taps</key> + <type>real_vector</type> + </param> + <param> + <name>Size (# phases)</name> + <key>size</key> + <value>32</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index 2cedb45a2..5b45466f5 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -176,6 +176,8 @@ <!-- Filter banks --> <block>blks2_synthesis_filterbank</block> <block>blks2_analysis_filterbank</block> + <!-- Polyphase filers --> + <block>blks2_pfb_arb_resampler_ccf</block> <!-- Other filters --> <block>gr_single_pole_iir_filter_xx</block> <block>gr_hilbert_fc</block> 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 > 0</check> <check>0 < $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/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..32139636a 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 bb40e1f16..577e4c330 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 |