commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r8485 - in grc/trunk: . src/grc_gnuradio src/grc_gnura


From: jblum
Subject: [Commit-gnuradio] r8485 - in grc/trunk: . src/grc_gnuradio src/grc_gnuradio/blocks src/grc_gnuradio/blocks/variables src/grc_gnuradio/data src/grc_gnuradio/usrp
Date: Sat, 24 May 2008 22:30:45 -0600 (MDT)

Author: jblum
Date: 2008-05-24 22:30:39 -0600 (Sat, 24 May 2008)
New Revision: 8485

Added:
   grc/trunk/src/grc_gnuradio/blocks/custom/
Modified:
   grc/trunk/setup.py
   grc/trunk/src/grc_gnuradio/FlowGraph.py
   grc/trunk/src/grc_gnuradio/Generator.py
   grc/trunk/src/grc_gnuradio/blocks/variables/variable_chooser.xml
   grc/trunk/src/grc_gnuradio/blocks/variables/variable_sink.xml
   grc/trunk/src/grc_gnuradio/blocks/variables/variable_slider.xml
   grc/trunk/src/grc_gnuradio/data/no_gui.tmpl
   grc/trunk/src/grc_gnuradio/data/wx_gui.tmpl
   grc/trunk/src/grc_gnuradio/usrp/simple_usrp.py
Log:
moved template callback code into block wrappers for respective blocks

Modified: grc/trunk/setup.py
===================================================================
--- grc/trunk/setup.py  2008-05-24 18:36:28 UTC (rev 8484)
+++ grc/trunk/setup.py  2008-05-25 04:30:39 UTC (rev 8485)
@@ -43,6 +43,7 @@
        'data/*.*',     
        'blocks/*.*',
        'blocks/conversions/*.xml',
+       'blocks/custom/*.xml',
        'blocks/error_correction/*.xml',
        'blocks/filters/*.xml',
        'blocks/graphical_sinks/*.xml',

Modified: grc/trunk/src/grc_gnuradio/FlowGraph.py
===================================================================
--- grc/trunk/src/grc_gnuradio/FlowGraph.py     2008-05-24 18:36:28 UTC (rev 
8484)
+++ grc/trunk/src/grc_gnuradio/FlowGraph.py     2008-05-25 04:30:39 UTC (rev 
8485)
@@ -44,7 +44,7 @@
                        #load variables
                        for block in filter(lambda b: b.get_key() in 
('variable', 'variable_slider', 'variable_chooser'), self.get_blocks()):
                                try: 
-                                       e = eval(block.get_make(), n, n)
+                                       e = 
eval(block.get_param('value').get_value(), n, n)
                                        n[block.get_id()] = e
                                except: pass
                #evaluate

Modified: grc/trunk/src/grc_gnuradio/Generator.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Generator.py     2008-05-24 18:36:28 UTC (rev 
8484)
+++ grc/trunk/src/grc_gnuradio/Generator.py     2008-05-25 04:30:39 UTC (rev 
8485)
@@ -79,6 +79,8 @@
                #separate blocks
                blocks = filter(lambda b: b not in variables and b.get_key() != 
'import', all_blocks)
                blocks = sorted(blocks, lambda x, y: cmp(x.get_id(), 
y.get_id())) 
+               #all callbacks
+               callbacks = sum([block.get_callbacks() for block in blocks], [])
                if self._flow_graph.get_option('generate_options') == 'no_gui': 
                
                        imports = sorted(set(imports)) #unique and sorted
                        #load the namespace
@@ -88,6 +90,7 @@
                                'variables': variables,
                                'blocks': blocks,
                                'connections': 
self._flow_graph.get_connections(),
+                               'callbacks': callbacks,
                        }
                        #build the template
                        t = Template(open(NO_GUI_TEMPLATE, 'r').read(), 
namespace)
@@ -95,21 +98,11 @@
                        imports.append('from grc_gnuradio import wxgui as 
grc_wxgui')
                        imports.append('import wx')
                        imports = sorted(set(imports)) #unique and sorted
-                       #separate variables with wx controls
-                       sliders = filter(lambda v: v.get_key() == 
'variable_slider', variables)
-                       choosers = filter(lambda v: v.get_key() == 
'variable_chooser', variables)
-                       variable_sinks = filter(lambda v: v.get_key() == 
'variable_sink', blocks)
-                       #all callbacks
-                       callbacks = list()
-                       for block in blocks: 
callbacks.extend(block.get_callbacks())
                        #load the namespace
                        namespace = {
                                'imports':      imports,
                                'flow_graph': self._flow_graph,
                                'variables': variables,
-                               'sliders': sliders,
-                               'choosers': choosers,
-                               'variable_sinks': variable_sinks,
                                'blocks': blocks,
                                'connections': 
self._flow_graph.get_connections(),
                                'callbacks': callbacks,

Modified: grc/trunk/src/grc_gnuradio/blocks/variables/variable_chooser.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/variables/variable_chooser.xml    
2008-05-24 18:36:28 UTC (rev 8484)
+++ grc/trunk/src/grc_gnuradio/blocks/variables/variable_chooser.xml    
2008-05-25 04:30:39 UTC (rev 8485)
@@ -8,7 +8,21 @@
 <block>
        <name>Variable Chooser</name>
        <key>variable_chooser</key>
-       <make>$(choices)[$value_index]</make>
+       <make>$(choices)[$value_index]
+_$(id)_control = grc_wxgui.$(chooser_type)_control(
+       window=tb.GetWin(), 
+       callback=_set_$(id),
+               #if $label.eval
+       label=$label,
+               #else
+       label="$id", 
+               #end if
+       index=$value_index,
+       choices=$choices,
+       labels=$labels,
+)
+#set $grid_pos = $grid_pos.eval
+tb.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])</make>
        <param>
                <name>Label</name>
                <key>label</key>

Modified: grc/trunk/src/grc_gnuradio/blocks/variables/variable_sink.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/variables/variable_sink.xml       
2008-05-24 18:36:28 UTC (rev 8484)
+++ grc/trunk/src/grc_gnuradio/blocks/variables/variable_sink.xml       
2008-05-25 04:30:39 UTC (rev 8485)
@@ -9,7 +9,8 @@
        <name>Variable Sink</name>
        <key>variable_sink</key>
        <import>from grc_gnuradio import blks2 as grc_blks2</import>
-       <make>grc_blks2.queue_sink_$(type.fcn)($vlen)</make>
+       <make>grc_blks2.queue_sink_$(type.fcn)($vlen)
+grc_blks2.queue_sink_thread($id, _set_$(variable))</make>
        <param>
                <name>Type</name>
                <key>type</key>
@@ -44,7 +45,7 @@
                <name>Variable</name>
                <key>variable</key>
                <value></value>
-               <type>string</type>             
+               <type>raw</type>                
        </param>
        <param>
                <name>Vec Length</name>
@@ -62,7 +63,5 @@
 Read samples from the input stream and write each sample to the variable. 
 
 The variable must be the id of an existing variable block.
-
-The variable sink is only supported in wx gui mode.
        </doc>
 </block>

Modified: grc/trunk/src/grc_gnuradio/blocks/variables/variable_slider.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/variables/variable_slider.xml     
2008-05-24 18:36:28 UTC (rev 8484)
+++ grc/trunk/src/grc_gnuradio/blocks/variables/variable_slider.xml     
2008-05-25 04:30:39 UTC (rev 8485)
@@ -8,7 +8,22 @@
 <block>
        <name>Variable Slider</name>
        <key>variable_slider</key>
-       <make>$value</make>
+       <make>$value
+_$(id)_control = grc_wxgui.slider_control(
+       window=tb.GetWin(), 
+       callback=_set_$(id),
+               #if $label.eval
+       label=$label,
+               #else
+       label="$id", 
+               #end if
+       value=$value,
+       min=$min,
+       max=$max,
+       num_steps=$num_steps,
+)
+#set $grid_pos = $grid_pos.eval
+tb.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])</make>
        <param>
                <name>Label</name>
                <key>label</key>

Modified: grc/trunk/src/grc_gnuradio/data/no_gui.tmpl
===================================================================
--- grc/trunk/src/grc_gnuradio/data/no_gui.tmpl 2008-05-24 18:36:28 UTC (rev 
8484)
+++ grc/trunk/src/grc_gnuradio/data/no_gui.tmpl 2008-05-25 04:30:39 UTC (rev 
8485)
@@ -7,6 +7,7 @@
 address@hidden variables the variable blocks
 address@hidden blocks the signal blocks
 address@hidden connections the connections
address@hidden callbacks the block callback strings
 ########################################################
 #import time
 #set $DIVIDER = '#'*50
@@ -28,6 +29,23 @@
 tb = gr.top_block()
 
 ########################################################
+##     Create Callbacks
+########################################################
+$DIVIDER
+# Callbacks
+$DIVIDER
+#for $var in $variables
+       #set $id = $var.get_id()
+       #set $var_callbacks = filter(lambda c: id in ''.join(c.split('(')[1:]), 
$callbacks)
+def _set_$(id)(_$id):
+       global $id
+       $id = _$id
+       #for $callback in $var_callbacks
+       $callback
+       #end for
+
+#end for
+########################################################
 ##     Create Variables
 ########################################################
 $DIVIDER

Modified: grc/trunk/src/grc_gnuradio/data/wx_gui.tmpl
===================================================================
--- grc/trunk/src/grc_gnuradio/data/wx_gui.tmpl 2008-05-24 18:36:28 UTC (rev 
8484)
+++ grc/trunk/src/grc_gnuradio/data/wx_gui.tmpl 2008-05-25 04:30:39 UTC (rev 
8485)
@@ -7,9 +7,6 @@
 address@hidden variables the variable blocks
 address@hidden blocks the signal blocks
 address@hidden connections the connections
address@hidden sliders variable blocks for sliders
address@hidden choosers variable blocks for choosers
address@hidden variable_sinks blocks for variable sinks
 address@hidden callbacks the block callback strings
 ########################################################
 #import time
@@ -43,13 +40,30 @@
 )
 
 ########################################################
+##     Create Callbacks
+########################################################
+$DIVIDER
+# Callbacks
+$DIVIDER
+#for $var in $variables
+       #set $id = $var.get_id()
+       #set $var_callbacks = filter(lambda c: id in ''.join(c.split('(')[1:]), 
$callbacks)
+def _set_$(id)(_$id):
+       global $id
+       $id = _$id
+       #for $callback in $var_callbacks
+       $callback
+       #end for
+
+#end for
+########################################################
 ##     Create Variables
 ########################################################
 $DIVIDER
 # Variables
 $DIVIDER
 #for $var in $variables
-$("%s = %s"%($var.get_id(), $var.get_make()))
+$("%s = %s"%($var.get_id(), $var.get_make()))  
 #end for
 
 ########################################################
@@ -79,61 +93,6 @@
        )
 )
 #end for
-########################################################
-##     Create Controls
-########################################################
-#for $control in $sliders + $choosers + $variable_sinks
-       #if $control in $variable_sinks
-               #set $id = $control.get_param('variable').evaluate()
-       #else
-               #set $id = $control.get_id()
-       #end if
-       #set $my_callbacks = filter(lambda c: id in ''.join(c.split('(')[1:]), 
$callbacks)
-
-$DIVIDER
-# Control for $id
-$DIVIDER
-def _set_$(id)(_$id):
-       global $id
-       $id = _$id
-       #for $callback in $my_callbacks
-       $callback
-       #end for
-       #if $control in $variable_sinks
-grc_blks2.queue_sink_thread($control.get_id(), _set_$(id))
-       #elif $control in $sliders
-_$(id)_control = grc_wxgui.slider_control(
-       window=tb.GetWin(), 
-       callback=_set_$(id),
-               #if $control.get_param('label').evaluate() 
-       label=$control.get_param('label').to_code(),
-               #else
-       label="$id", 
-               #end if
-       value=$control.get_param('value').to_code(),
-       min=$control.get_param('min').to_code(),
-       max=$control.get_param('max').to_code(),
-       num_steps=$control.get_param('num_steps').to_code(),
-)
-       #elif $control in $choosers
-_$(id)_control = 
grc_wxgui.$(control.get_param('chooser_type').to_code())_control(
-       window=tb.GetWin(), 
-       callback=_set_$(id),
-               #if $control.get_param('label').evaluate() 
-       label=$control.get_param('label').to_code(),
-               #else
-       label="$id", 
-               #end if
-       index=$control.get_param('value_index').to_code(),
-       choices=$control.get_param('choices').to_code(),
-       labels=$control.get_param('labels').to_code(),
-)      
-       #end if
-       #if $control not in $variable_sinks
-               #set $grid_pos = $control.get_param('grid_pos').evaluate()
-tb.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
-       #end if
-#end for
        
 tb.Run()
 

Modified: grc/trunk/src/grc_gnuradio/usrp/simple_usrp.py
===================================================================
--- grc/trunk/src/grc_gnuradio/usrp/simple_usrp.py      2008-05-24 18:36:28 UTC 
(rev 8484)
+++ grc/trunk/src/grc_gnuradio/usrp/simple_usrp.py      2008-05-25 04:30:39 UTC 
(rev 8485)
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-#
 # Copyright 2008 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio





reply via email to

[Prev in Thread] Current Thread [Next in Thread]