commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7813 - in grc/branches/grc_reloaded: . src/grc/platfo


From: jblum
Subject: [Commit-gnuradio] r7813 - in grc/branches/grc_reloaded: . src/grc/platforms/gnuradio_python src/grc/platforms/gnuradio_python/blocks src/grc/platforms/gnuradio_python/blocks/graphical_sinks src/grc/platforms/gnuradio_python/blocks/variables src/grc/platforms/gnuradio_python/data
Date: Sun, 24 Feb 2008 12:01:07 -0700 (MST)

Author: jblum
Date: 2008-02-24 12:01:07 -0700 (Sun, 24 Feb 2008)
New Revision: 7813

Added:
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_scopesink2.xml
Modified:
   grc/branches/grc_reloaded/setup.py
   grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_button.xml
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_drop_down.xml
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
   
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/block_tree.xml
   grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/wx_gui.tmpl
Log:
wxgui scopesink and graphical window support

Modified: grc/branches/grc_reloaded/setup.py
===================================================================
--- grc/branches/grc_reloaded/setup.py  2008-02-24 18:54:36 UTC (rev 7812)
+++ grc/branches/grc_reloaded/setup.py  2008-02-24 19:01:07 UTC (rev 7813)
@@ -45,6 +45,7 @@
        'platforms/gnuradio_python/blocks/*.*',
        'platforms/gnuradio_python/blocks/sources/*.xml',
        'platforms/gnuradio_python/blocks/sinks/*.xml',
+       'platforms/gnuradio_python/blocks/graphical_sinks/*.xml',
        'platforms/gnuradio_python/blocks/operators/*.xml',
        'platforms/gnuradio_python/blocks/variables/*.xml',
 ]

Modified: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py    
2008-02-24 18:54:36 UTC (rev 7812)
+++ grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py    
2008-02-24 19:01:07 UTC (rev 7813)
@@ -43,7 +43,6 @@
                #get imports
                imports = ['from gnuradio import gr', 'from gnuradio.gr import 
firdes', 'import math', 'import cmath']
                for block in all_blocks: imports.extend(block.get_imports())
-               imports = set(imports) #all entries unique
                #separate variables
                variables = filter(lambda b: 
b.get_key().startswith('variable'), all_blocks)
                variables = sorted(variables, lambda x, y: cmp(x.get_id(), 
y.get_id())) 
@@ -51,6 +50,7 @@
                blocks = filter(lambda b: b not in variables and b.get_key() != 
'options', all_blocks)
                blocks = sorted(blocks, lambda x, y: cmp(x.get_id(), 
y.get_id())) 
                if self._flow_graph.get_option('generate_options') == 'no_gui': 
                
+                       imports = sorted(set(imports)) #unique and sorted
                        #load the namespace
                        namespace = {
                                'imports':      imports,
@@ -62,12 +62,15 @@
                        #build the template
                        t = Template(open(NO_GUI_TEMPLATE, 'r').read(), 
namespace)
                elif self._flow_graph.get_option('generate_options') == 
'wx_gui':               
-                       imports.add('from grc_gnuradio.wxgui import Controls')
-                       imports.add('import wx')
+                       imports.append('from grc_gnuradio.wxgui import 
Controls')
+                       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)
                        buttons = filter(lambda v: v.get_key() == 
'variable_button', variables)
                        drop_downs = filter(lambda v: v.get_key() == 
'variable_drop_down', variables)
+                       #graphical sinks
+                       graphical_sinks = filter(lambda b: 
b.get_key().startswith('wxgui'), blocks)
                        #all callbacks
                        callbacks = list()
                        for block in blocks: 
callbacks.extend(block.get_callbacks())
@@ -80,6 +83,7 @@
                                'buttons': buttons,
                                'drop_downs': drop_downs,
                                'blocks': blocks,
+                               'graphical_sinks': graphical_sinks,
                                'connections': 
self._flow_graph.get_connections(),
                                'callbacks': callbacks,
                        }

Added: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_scopesink2.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_scopesink2.xml
                             (rev 0)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/graphical_sinks/wxgui_scopesink2.xml
     2008-02-24 19:01:07 UTC (rev 7813)
@@ -0,0 +1,89 @@
+<?xml version="1.0"?>
+<!DOCTYPE block SYSTEM "../block.dtd">
+<!-- 
+###################################################
+##Scope Sink
+###################################################
+ -->
+<block>
+       <name>Scope Sink</name>
+       <key>wxgui_scopesink2</key>
+       <import>from gnuradio.wxgui import scopesink2</import>
+       <make>scopesink2.$type:fcn(
+       _frame, 
+       title=$title, 
+       sample_rate=$samp_rate, 
+       frame_decim=$frame_decim, 
+       v_scale=$v_scale, 
+       t_scale=$t_scale, 
+       num_inputs=$num_inputs,
+)</make>
+       <callback>set_sample_rate($samp_rate)</callback>
+       <param>
+               <name>Type</name>       
+               <key>type</key>
+               <value>complex</value>
+               <type>enum</type>
+               <option>
+                       <name>Complex</name>
+                       <key>complex</key>
+                       <opt>fcn:scope_sink_c</opt>
+               </option>
+               <option>
+                       <name>Float</name>
+                       <key>float</key>
+                       <opt>fcn:scope_sink_f</opt>
+               </option>
+       </param>
+       <param>
+               <name>Title</name>      
+               <key>title</key>
+               <value>Scope Sink</value>
+               <type>string</type>
+       </param>
+       <param>
+               <name>Sample Rate</name>        
+               <key>samp_rate</key>
+               <value>samp_rate</value>
+               <type>real</type>
+       </param>
+       <param>
+               <name>Frame Decimation</name>   
+               <key>frame_decim</key>
+               <value>15</value>
+               <type>int</type>
+       </param>
+       <param>
+               <name>V Scale</name>    
+               <key>v_scale</key>
+               <value>1000</value>
+               <type>real</type>
+       </param>
+       <param>
+               <name>T Scale</name>    
+               <key>t_scale</key>
+               <value>.001</value>
+               <type>real</type>
+       </param>
+       <param>
+               <name>Num Inputs</name> 
+               <key>num_inputs</key>
+               <value>1</value>
+               <type>int</type>
+       </param>        
+       <param>
+               <name>Grid Position</name>
+               <key>grid_pos</key>
+               <value>0, 0, 1, 1</value>
+               <type>int_vector</type>
+       </param>
+       <check>len($grid_pos) == 4</check>
+       <sink>
+               <name>in</name>
+               <type>$type</type>
+               <nports>$num_inputs</nports>
+       </sink>
+       <doc>
+Use the Grid Position (row, column, row span, column span) to position the 
graphical element in the window.
+       </doc>
+</block>

Modified: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_button.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_button.xml
    2008-02-24 18:54:36 UTC (rev 7812)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_button.xml
    2008-02-24 19:01:07 UTC (rev 7813)
@@ -37,8 +37,17 @@
                <value>1</value>
                <type>raw</type>        
        </param>
+       <param>
+               <name>Grid Position</name>
+               <key>grid_pos</key>
+               <value>0, 0, 1, 1</value>
+               <type>int_vector</type>
+       </param>
+       <check>len($grid_pos) == 4</check>
        <doc>
 This block creates a variable with a button. 
 The button has 2 states, on and off.
+
+Use the Grid Position (row, column, row span, column span) to position the 
graphical element in the window.
        </doc>
 </block>

Modified: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_drop_down.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_drop_down.xml
 2008-02-24 18:54:36 UTC (rev 7812)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_drop_down.xml
 2008-02-24 19:01:07 UTC (rev 7813)
@@ -21,10 +21,19 @@
                <value>[1, 2, 3]</value>
                <type>raw</type>
        </param>
+       <param>
+               <name>Grid Position</name>
+               <key>grid_pos</key>
+               <value>0, 0, 1, 1</value>
+               <type>int_vector</type>
+       </param>
+       <check>len($grid_pos) == 4</check>
        <check>$choices[$value_index]</check>
        <doc>
 This block creates a variable with a drop down. 
 The value index is the index of a particular choice.
 The choices must be a list of possible values.
+
+Use the Grid Position (row, column, row span, column span) to position the 
graphical element in the window.
        </doc>
 </block>

Modified: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
    2008-02-24 18:54:36 UTC (rev 7812)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
    2008-02-24 19:01:07 UTC (rev 7813)
@@ -33,6 +33,13 @@
                <value>100</value>
                <type>int</type>
        </param>
+       <param>
+               <name>Grid Position</name>
+               <key>grid_pos</key>
+               <value>0, 0, 1, 1</value>
+               <type>int_vector</type>
+       </param>
+       <check>len($grid_pos) == 4</check>
        <check>$min &lt;= $value &lt;= $max</check>
        <check>$min &lt; $max</check>
        <check>0 &lt; $num_steps &lt;= 1000</check>
@@ -41,5 +48,7 @@
 The value must be a real number.
 The value must be between the minimum and the maximum.
 The number of steps must be between 0 and 1000.
+
+Use the Grid Position (row, column, row span, column span) to position the 
graphical element in the window.
        </doc>
 </block>

Modified: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/block_tree.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/block_tree.xml 
    2008-02-24 18:54:36 UTC (rev 7812)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/block_tree.xml 
    2008-02-24 19:01:07 UTC (rev 7813)
@@ -33,7 +33,7 @@
        <cat>
                <name>Graphical Sinks</name>
                <block>number_sink</block>
-               <block>scope_sink</block>       
+               <block>wxgui_scopesink2</block> 
                <block>fft_sink</block>
                <block>constellation_sink</block>
                <block>waterfall_sink</block>

Modified: 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/wx_gui.tmpl
===================================================================
--- 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/wx_gui.tmpl    
    2008-02-24 18:54:36 UTC (rev 7812)
+++ 
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/wx_gui.tmpl    
    2008-02-24 19:01:07 UTC (rev 7813)
@@ -11,6 +11,7 @@
 address@hidden buttons variable blocks for buttons
 address@hidden drop_downs variable blocks for drop_downs
 address@hidden callbacks the block callback strings
address@hidden graphical_sinks the graphical sink blocks
 ########################################################
 #import time
 #import os
@@ -25,33 +26,54 @@
 $flow_graph.get_option('description')
 $('"""')
 
+########################################################
+##     Create a callback function
+########################################################
 #def make_callback($id)
        #set $my_callbacks = filter(lambda c: id in c, $callbacks)
        #if $my_callbacks
-               def callback(value):
-                       $id = value
+def _callback(value):
+       $id = value
                #for $callback in $my_callbacks
-                       exec("""$callback""")
+       exec("""$callback""")
                #end for
        #else
-               def callback(value): pass#slurp
+def _callback(value): pass#slurp
        #end if         
 #end def
 
+########################################################
+##     Create Imports
+########################################################
 #for $imp in $imports
 $imp
 #end for
 
+########################################################
+##     Create wx objects
+########################################################
+_app = wx.App()
+_frame = wx.Frame(None , -1, $('"%s - Executing: %s"'%($MAIN_WINDOW_PREFIX, 
$flow_graph.get_option('name'))))
+_grid = wx.GridBagSizer(5, 5)
+
+########################################################
+##     Create Variables
+########################################################
 #for $var in $variables
 $("%s = %s"%($var.get_id(), $var.get_make()))
 #end for
 
+########################################################
+##     Create Blocks
+########################################################
 #for $blk in $blocks
 $("%s = %s"%($blk.get_id(), $blk.get_make()))
 #end for
 
+########################################################
+##     Create Connections
+########################################################
 tb = gr.top_block()
-
 #for $con in $connections
        #set $source = $con.get_source()
        #set $sink = $con.get_sink()
@@ -64,63 +86,80 @@
 )
 #end for
 
-class Frame(wx.Frame):
-               
-       def __init__(self):             
-               wx.Frame.__init__(self, None , -1, $('"%s - Executing: 
%s"'%($MAIN_WINDOW_PREFIX, $flow_graph.get_option('name'))))
-#if $WX_APP_ICON
-               self.SetIcon(wx.Icon("$os.path.abspath($WX_APP_ICON)", 
wx.BITMAP_TYPE_ANY))
-#end if                
-               self.SetSizeHints(400, 100)
-               main_box = wx.BoxSizer(wx.VERTICAL)             
+########################################################
+##     Graphical Sinks
+########################################################
+#for $graphical_sink in $graphical_sinks
+       #set $grid_pos = $graphical_sink.get_param('grid_pos').evaluate()
+_grid.Add($(graphical_sink.get_id()).win, wx.GBPosition($grid_pos[0], 
$grid_pos[1]), wx.GBSpan($grid_pos[2], $grid_pos[3]))
+#end for
+
+########################################################
+##     Create Sliders
+########################################################
 #for $slider in $sliders
 $make_callback($slider.get_id())
-               slider = Controls.Slider(
-                       window=self, 
-                       callback=callback, 
-                       title="$slider.get_id()", 
-                       value=$slider.get_param('value').to_code(),
-                       min=$slider.get_param('min').to_code(),
-                       max=$slider.get_param('max').to_code(),
-                       num_steps=$slider.get_param('num_steps').to_code(),
-               )
-               main_box.Add(slider, 0, wx.ALIGN_CENTER)
-#end for               
+slider = Controls.Slider(
+       window=_frame, 
+       callback=_callback, 
+       title="$slider.get_id()", 
+       value=$slider.get_param('value').to_code(),
+       min=$slider.get_param('min').to_code(),
+       max=$slider.get_param('max').to_code(),
+       num_steps=$slider.get_param('num_steps').to_code(),
+)
+#set $grid_pos = $slider.get_param('grid_pos').evaluate()
+_grid.Add(slider, wx.GBPosition($grid_pos[0], $grid_pos[1]), 
wx.GBSpan($grid_pos[2], $grid_pos[3]))
+#end for
+
+########################################################
+##     Create Drop Downs
+########################################################               
 #for $drop_down in $drop_downs
 $make_callback($drop_down.get_id())
-               drop_down = Controls.DropDown(
-                       window=self, 
-                       callback=callback, 
-                       title="$drop_down.get_id()", 
-                       index=$drop_down.get_param('value_index').to_code(),
-                       choices=$drop_down.get_param('choices').to_code(),
-               )
-               main_box.Add(drop_down, 0, wx.ALIGN_CENTER)
+drop_down = Controls.DropDown(
+       window=_frame, 
+       callback=_callback, 
+       title="$drop_down.get_id()", 
+       index=$drop_down.get_param('value_index').to_code(),
+       choices=$drop_down.get_param('choices').to_code(),
+)
+#set $grid_pos = $drop_down.get_param('grid_pos').evaluate()
+_grid.Add(drop_down, wx.GBPosition($grid_pos[0], $grid_pos[1]), 
wx.GBSpan($grid_pos[2], $grid_pos[3]))
 #end for
+
+########################################################
+##     Create Buttons
+########################################################
 #for $button in $buttons
 $make_callback($button.get_id())
-               button = Controls.Button(
-                       window=self, 
-                       callback=callback, 
-                       title="$button.get_id()", 
-                       on=$(button.get_param('value_index').to_code() == 'on'),
-                       on_state=$button.get_param('off_value').to_code(),
-                       off_state=$button.get_param('on_value').to_code(),
-               )
-               main_box.Add(button, 0, wx.ALIGN_CENTER)
-#end for               
-               self.Bind(wx.EVT_CLOSE, self._quit)     
-               self.SetSizerAndFit(main_box)
-               self.Show()
-               tb.start()
-                       
-       def _quit(self, event):
-               self.Destroy()
-               tb.stop()
-
-app = wx.App()
-app.SetTopWindow(Frame())
-app.MainLoop()
+button = Controls.Button(
+       window=_frame, 
+       callback=_callback, 
+       title="$button.get_id()", 
+       on=$(button.get_param('value_index').to_code() == 'on'),
+       on_state=$button.get_param('off_value').to_code(),
+       off_state=$button.get_param('on_value').to_code(),
+)
+#set $grid_pos = $button.get_param('grid_pos').evaluate()
+_grid.Add(button, wx.GBPosition($grid_pos[0], $grid_pos[1]), 
wx.GBSpan($grid_pos[2], $grid_pos[3]))
+#end for       
+       
+########################################################
+##     Setup GUI
+########################################################
+#if $WX_APP_ICON
+_frame.SetIcon(wx.Icon("$os.path.abspath($WX_APP_ICON)", wx.BITMAP_TYPE_ANY))
+#end if        
+_frame.SetSizeHints(400, 100)
+def _quit(event):
+       _frame.Destroy()
+       tb.stop()
+_frame.Bind(wx.EVT_CLOSE, _quit)       
+_frame.SetSizerAndFit(_grid)                   
+_frame.Show()
+tb.start()
+_app.SetTopWindow(_frame)
+_app.MainLoop()
 exit(0)
 
-





reply via email to

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