Merge branch 'master' of http://gnuradio.org/git/gnuradio into grc
authorJosh Blum <josh@joshknows.com>
Tue, 25 Aug 2009 23:51:45 +0000 (16:51 -0700)
committerJosh Blum <josh@joshknows.com>
Tue, 25 Aug 2009 23:51:45 +0000 (16:51 -0700)
21 files changed:
gnuradio-core/src/python/gnuradio/eng_option.py
gr-wxgui/src/python/constants.py
gr-wxgui/src/python/fft_window.py
grc/Makefile.inc
grc/base/Block.py
grc/base/Platform.py
grc/base/Port.py
grc/blocks/options.xml
grc/blocks/pad_sink.xml
grc/blocks/pad_source.xml
grc/blocks/parameter.xml
grc/gui/ActionHandler.py
grc/gui/Actions.py
grc/gui/Bars.py
grc/gui/Dialogs.py
grc/gui/Platform.py
grc/gui/Port.py
grc/python/Platform.py
grc/python/Port.py
grc/python/flow_graph.tmpl
grc/todo.txt

index 09c3e1d87771a0a5a26ea2ce0f52b2f62a8def06..e10235f143958329b3ccfbdb70f6e08f4d91eb33 100644 (file)
 
 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))
index 5e1395701eaa9c923ea5c0280aa92c7a9ffdfbb3..8ff7fa8fee848f44870a23481375270133b179c3 100644 (file)
@@ -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'
index ba5711d109100d7528bedf79a68fccc63589b52e..0529e6a5d6d77eb2070fbda7468fa2c1cecb1fb8 100644 (file)
@@ -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]
index 96ee11b67e721d44581a5c1d296ae6f287ca497c..c45d1ce1f33bee6cd49262aa8016f43a25447d0f 100644 (file)
@@ -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
index d5e1047852b7df5bfcd71b89135483debc183f18..349e71f76b212f322d42a479161735186941cd64 100644 (file)
@@ -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()
index 02d6d2319257e969c1b8b4f151b02556698df6ab..db7ade9a3a941f097c0873ae0295e106e27e024c 100644 (file)
@@ -171,6 +171,5 @@ class Platform(_Element):
        FlowGraph = _FlowGraph
        Connection = _Connection
        Block = _Block
-       Source = _Port
-       Sink = _Port
+       Port = _Port
        Param = _Param
index f4e8e5e1fb2a6f648aef6118b545b5a9e0d3354d..8e60d50931c3e91f60203c6d3c93c9d911c472f4 100644 (file)
@@ -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):
index 18d6e2f0c99fc0818a5177950cc438672e6f55d0..a28a0b1439eff5ef6bdf0c6eff1525c9dacda5d9 100644 (file)
@@ -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>
index 477f2ad13a044a8911bd2e8db37488fdb522059a..999de315dbb166f7b057459d375be982e6a8401e 100644 (file)
@@ -8,6 +8,20 @@
        <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>
index b6ef2c55d1e2f2e6bbc3770ff066716d4da2b644..26491adb3986b16455e3ae07b0eac7f3b43263b2 100644 (file)
@@ -8,6 +8,20 @@
        <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 &gt; 0</check>
        <check>0 &lt; $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>
index 5d08c4b394662f8824877f13ea2153cd559e1c86..e35b8f4d1d8bc7c7ac9bd14a06acf6cb6a1eb0ae 100644 (file)
@@ -45,7 +45,7 @@
                </option>
                <option>
                        <name>Int</name>
-                       <key>int</key>
+                       <key>intx</key>
                        <opt>type:int</opt>
                </option>
                <option>
                        <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>
index ff137f6697074b657ece3f5ab2d90ce6a2db2c50..9af580e8e1e5721ad7c3f65cff0065eac69b5825 100644 (file)
@@ -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
                ##################################################
index 3695e09ef3d7abdddc7b178d132099f83f46e92d..c3ef2711acb053433c9ea0ea6a23dbfac469fcdd 100644 (file)
@@ -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),
index e0c547eba5348af90130848d0c4b737aff961cdf..697d48a3ced7c3bea8a578c4ae10d0db8f47b1b8 100644 (file)
@@ -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,
        ]),
index 8d764e28e38e8584302026ccae4fbde33133495d..3cf617b92c8e03b1a06fdd6d6e457dd8a450f613 100644 (file)
@@ -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()))
index a32b0209ffb2815c2e769a673dac58af1239b26a..1530a69d63f11cbe7d74eb8d92836a946337e4bc 100644 (file)
@@ -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)
index d1f36f8b963659aea5d5e8130c8def7ffb3bd965..6fc2c4b155aeec04f26cb69131aa3065d0aab628 100644 (file)
@@ -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
index d55dbf4ce71a224fa89fd710a396f466db7c2391..cab25d348fd3d29665095c77bc3ba2eb33f8f729 100644 (file)
@@ -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
index daf8f9ca34c1f687fffc3e54dac26af3dc35b6e3..f71c5fa35f87e768a979c4cc84e471deb3408704 100644 (file)
@@ -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)
index df346dd165567002a34fcfbcd2787818ef43cbea..924a280c4548cdd71d0d1b182d262f7dc4b45bcc 100644 (file)
@@ -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()
index bb40e1f160fe4009dec974596cefed2ca38f0284..ad02bf79065f77ba6dce8d0fc552d423195035f6 100644 (file)
@@ -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