commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5541 - in grc/branches/jblum_work: data license notes


From: jblum
Subject: [Commit-gnuradio] r5541 - in grc/branches/jblum_work: data license notes src src/Graphics src/SignalBlockDefs
Date: Sat, 26 May 2007 22:35:18 -0600 (MDT)

Author: jblum
Date: 2007-05-26 22:35:18 -0600 (Sat, 26 May 2007)
New Revision: 5541

Added:
   grc/branches/jblum_work/data/preferences.grc.dtd
Modified:
   grc/branches/jblum_work/license/README.txt
   grc/branches/jblum_work/notes/notes.txt
   grc/branches/jblum_work/src/FlowGraphApp.py
   grc/branches/jblum_work/src/Graphics/Dialogs.py
   grc/branches/jblum_work/src/Preferences.py
   grc/branches/jblum_work/src/SignalBlockDefs/Conversions.py
   grc/branches/jblum_work/src/SignalBlockDefs/Misc.py
   grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py
Log:
preferences dtd, initial work on selector block

Added: grc/branches/jblum_work/data/preferences.grc.dtd
===================================================================
--- grc/branches/jblum_work/data/preferences.grc.dtd                            
(rev 0)
+++ grc/branches/jblum_work/data/preferences.grc.dtd    2007-05-27 04:35:18 UTC 
(rev 5541)
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!-- 
+Copyright 2007 Free Software Foundation, Inc.
+This file is part of GNU Radio
+
+GNU Radio Companion is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
+-->
+<!--
+       preferences.grc.dtd 
+       Josh Blum
+       The document type definitions for grc preferences.
+-->
+<!DOCTYPE preferences [
+       <!-- The preferences contains:
+               identifying information: time stamp, host name, version, 
+               and a list of categories, each with their own preferences.    
-->
+       <!ELEMENT preferences (timestamp?, hostname?, version?, categories>
+               <!ELEMENT timestamp (#PCDATA)>  <!-- The time stamp for the 
modification date. (optional) -->
+               <!ELEMENT hostname (#PCDATA)>   <!-- The hostname of the 
computer. (optional) -->
+               <!ELEMENT version (#PCDATA)>    <!-- The program and program 
version.  (optional) -->
+               <!ELEMENT categories (category*)>       <!-- The list of 
categories. (tag required) -->
+                       <!ELEMENT category (title?, prefs)>     <!-- A 
category. (0 or more) -->
+                               <!ELEMENT title (#PCDATA)>      <!-- The title 
of the category. (optional) -->
+                               <!ELEMENT prefs (pref*)>        <!-- The list 
of preferences for this category. (tag required) -->
+                                       <!ELEMENT pref (#PCDATA)>       <!-- A 
preference. (0 or more) -->
+]>

Modified: grc/branches/jblum_work/license/README.txt
===================================================================
--- grc/branches/jblum_work/license/README.txt  2007-05-25 19:59:03 UTC (rev 
5540)
+++ grc/branches/jblum_work/license/README.txt  2007-05-27 04:35:18 UTC (rev 
5541)
@@ -11,9 +11,3 @@
 
 If you have questions, problems, suggestions, or want to contribute,
 please email me at jblum at jhu dot edu
-
-Special Thanks:
-
-Patrick Strasser - creating the GRC icon
-
-Achilleas Anastasopoulos - added trellis support

Modified: grc/branches/jblum_work/notes/notes.txt
===================================================================
--- grc/branches/jblum_work/notes/notes.txt     2007-05-25 19:59:03 UTC (rev 
5540)
+++ grc/branches/jblum_work/notes/notes.txt     2007-05-27 04:35:18 UTC (rev 
5541)
@@ -17,7 +17,6 @@
 -math expressions, pi, e, sin, cos, tan, log, ln
 -stdin/out communication protocal (non graphical)
 -include dtd in saved flow graphs
--create dtd for preferences
 
 ############   wxPython Features:      ####################
 -dump wx running graph to png?

Modified: grc/branches/jblum_work/src/FlowGraphApp.py
===================================================================
--- grc/branches/jblum_work/src/FlowGraphApp.py 2007-05-25 19:59:03 UTC (rev 
5540)
+++ grc/branches/jblum_work/src/FlowGraphApp.py 2007-05-27 04:35:18 UTC (rev 
5541)
@@ -63,8 +63,7 @@
                self.slider_width = slider_width = int(slider_width)    #make 
sure width is an integer number of pixels
                ### make the slider     ###                             
                self.slider = slider = wx.Slider(parent, -1, 
size=wx.Size(slider_width, SLIDER_HEIGHT), style=wx.SL_HORIZONTAL)              
           
-               try:            
-                       slider.SetRange(0, num_steps)
+               try: slider.SetRange(0, num_steps)
                except Exception, e:
                        sys.stderr.write('Slider, "%s", has too many 
steps!\n'%key)
                        sys.exit(1)
@@ -225,7 +224,16 @@
                        input_socket_index = int(find_data(connection, 
'input_socket_index'))
                        output_signal_block_id = find_data(connection, 
'output_signal_block_id')
                        output_socket_index = int(find_data(connection, 
'output_socket_index')) 
-                       self.connect(#  use this flow graph's connect method    
#
+                       #TODO: raise error if input and output block are meta 
blocks                    
+                       if hasattr(signal_blocks_dict[output_signal_block_id], 
'meta_block'):
+                               
signal_blocks_dict[output_signal_block_id].register_input(
+                                       output_socket_index, 
signal_blocks_dict[input_signal_block_id], input_socket_index,
+                               )
+                       elif hasattr(signal_blocks_dict[input_signal_block_id], 
'meta_block'):  
+                               
signal_blocks_dict[input_signal_block_id].register_output(
+                                       input_socket_index, 
signal_blocks_dict[output_signal_block_id], output_socket_index,
+                               )
+                       else: self.connect(#    use this flow graph's connect 
method    #
                                (signal_blocks_dict[output_signal_block_id], 
output_socket_index),
                                (signal_blocks_dict[input_signal_block_id], 
input_socket_index))
 

Modified: grc/branches/jblum_work/src/Graphics/Dialogs.py
===================================================================
--- grc/branches/jblum_work/src/Graphics/Dialogs.py     2007-05-25 19:59:03 UTC 
(rev 5540)
+++ grc/branches/jblum_work/src/Graphics/Dialogs.py     2007-05-27 04:35:18 UTC 
(rev 5541)
@@ -129,6 +129,13 @@
                self.set_comments("""\
 Thank you to all those from the mailing list who tested GNU Radio Companion 
and offered advice.
 --
+Special Thanks:
+A. Brinton Cooper -> starting the project
+CER Technology Fellowship Grant -> initial funding
+William R. Kenan Jr. Fund -> usrp & computers
+Patrick Strasser -> the GRC icon
+Achilleas Anastasopoulos -> trellis support
+--
 GNU Radio Companion, \
 This file is part of GNU Radio
 GRC comes with ABSOLUTELY NO WARRANTY. \

Modified: grc/branches/jblum_work/src/Preferences.py
===================================================================
--- grc/branches/jblum_work/src/Preferences.py  2007-05-25 19:59:03 UTC (rev 
5540)
+++ grc/branches/jblum_work/src/Preferences.py  2007-05-27 04:35:18 UTC (rev 
5541)
@@ -118,7 +118,6 @@
        categories = find_data(preferences, 'categories')
        for i,category in enumerate(categories):
                category = find_data([category], 'category')
-               title = find_data(category, 'title')
                prefs = find_data(category, 'prefs')
                for j,pref in enumerate(prefs):
                        pref = find_data([pref], 'pref')

Modified: grc/branches/jblum_work/src/SignalBlockDefs/Conversions.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Conversions.py  2007-05-25 
19:59:03 UTC (rev 5540)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Conversions.py  2007-05-27 
04:35:18 UTC (rev 5541)
@@ -158,7 +158,7 @@
        sb.add_param('Num Inputs', Int(3, min=1, max=MAX_NUM_SOCKETS), 
                                        show_label=False, 
input_sockets_controller=True)
        sb.add_param('Vector Length', vlen)
-       sb.set_docs('''2 <= Num Inputs <= %d'''%MAX_NUM_SOCKETS)        
+       sb.set_docs('''1 <= Num Inputs <= %d'''%MAX_NUM_SOCKETS)        
        return sb, lambda fg, type, num_inputs, vlen: 
gr.interleave(type.parse().get_num_bytes()*vlen.parse())
        
 def Deinterleave(sb):
@@ -170,7 +170,7 @@
        sb.add_param('Num Outputs', Int(3, min=1, max=MAX_NUM_SOCKETS), 
                                        show_label=False, 
output_sockets_controller=True)       
        sb.add_param('Vector Length', vlen)
-       sb.set_docs('''2 <= Num Outputs <= %d'''%MAX_NUM_SOCKETS)       
+       sb.set_docs('''1 <= Num Outputs <= %d'''%MAX_NUM_SOCKETS)       
        return sb, lambda fg, type, num_outputs, vlen: 
gr.deinterleave(type.parse().get_num_bytes()*vlen.parse())
        
 def StreamsToStream(sb):
@@ -185,7 +185,7 @@
        sb.add_param('Vector Length', vlen)
        sb.set_docs('''\
 Interleave N streams into a single stream.     
-2 <= Num Streams <= %d'''%MAX_NUM_SOCKETS)     
+1 <= Num Streams <= %d'''%MAX_NUM_SOCKETS)     
        return sb, lambda fg, type, num_streams, vlen: 
fcn(type.parse().get_num_bytes()*vlen.parse(), num_streams.parse())
        
 def StreamToStreams(sb):
@@ -200,7 +200,7 @@
        sb.add_param('Vector Length', vlen)
        sb.set_docs('''\
 Deinterleave a stream into N streams.
-2 <= Num Streams <= %d'''%MAX_NUM_SOCKETS)     
+1 <= Num Streams <= %d'''%MAX_NUM_SOCKETS)     
        return sb, lambda fg, type, num_streams, vlen: 
fcn(type.parse().get_num_bytes()*vlen.parse(), num_streams.parse())
        
 def StreamsToVector(sb):

Modified: grc/branches/jblum_work/src/SignalBlockDefs/Misc.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Misc.py 2007-05-25 19:59:03 UTC 
(rev 5540)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Misc.py 2007-05-27 04:35:18 UTC 
(rev 5541)
@@ -25,6 +25,7 @@
 from DataType import *
 from gnuradio import gr
 from SignalBlockConstants import default_samp_rate,all_choices
+from Constants import MAX_NUM_SOCKETS
 
 def Throttle(sb):
        fcn = gr.throttle
@@ -73,4 +74,80 @@
        sb.add_param('Note', String(''))
        return sb, lambda *args: None   
 
+#######################################################################################
+##     Selector Def and Selector Class
+#######################################################################################
+
+class selector_handler:
+       """ This selector handler class replaces an signal block,
+               and instead, manages connections between its inputs and outputs.
+               The selector handler will only allow one input and output to be 
connected. 
+               The inputs and outputs are registered in the selector handler 
when the flow graph is constructed.
+               The input and output are set via access methods and can be 
changed at runtime.
+               Invalid connection indexes cause a complete disconnection.      
"""     
+               
+       meta_block = True       #attribute to tell the flow graph app that this 
is not a real block
+               
+       def __init__(self, fg, input_index=-1, output_index=-1):
+               """ Create data structures to hold input/output blocks.
+                       Store initial input index and output index.     """
+               self.fg = fg
+               self.inputs = dict()
+               self.outputs = dict()   #map indexes to a (signal block, socket 
index)
+               self.current_connection = None
+               self.input_index = self.output_index = -1
+               self.set_input_index(input_index)
+               self.set_output_index(output_index)
+               
+       def set_input_index(self, input_index):
+               """ Set the input index.        """
+               self.input_index = input_index
+               self._update_connections()
+               
+       def set_output_index(self, output_index):
+               """ Set the output index.       """
+               self.output_index = output_index
+               self._update_connections()
+               
+       def register_input(self, input_index, signal_block, socket_index):
+               """     Store the block,index tuple in the inputs dict. """
+               self.inputs[input_index] = (signal_block, socket_index)
+               self._update_connections()
+               
+       def register_output(self, output_index, signal_block, socket_index):
+               """     Store the block,index tuple in the outputs dict.        
"""
+               self.outputs[output_index] = (signal_block, socket_index)
+               self._update_connections()
+               
+       def _update_connections(self):
+               """ Disconnect the current connection and then try to connect 
the blocks at the input/output index.     """                     
+               if self.current_connection != None:
+                       self.fg.disconnect(*self.current_connection)
+                       self.current_connection = None
+               if self.inputs.has_key(self.input_index) and 
self.outputs.has_key(self.output_index):
+                       self.current_connection = 
self.outputs[self.output_index], self.inputs[self.input_index]
+                       self.fg.connect(*self.current_connection)
+               
+def Selector(sb):
+       type = Enum(all_choices, 1)
+       vlen = Int(1, min=1)
+       sb.add_input_socket('in', Variable(type), vlen=vlen)
+       sb.add_output_socket('out', Variable(type), vlen=vlen)
+       sb.add_param('Type', type, False, type=True)
+       sb.add_param('Num Inputs', Int(1, min=1, max=MAX_NUM_SOCKETS), 
+                                       show_label=False, 
input_sockets_controller=True)        
+       sb.add_param('Num Outputs', Int(1, min=1, max=MAX_NUM_SOCKETS), 
+                                       show_label=False, 
output_sockets_controller=True)       
+       sb.add_param('Vector Length', vlen)
+       sb.add_param('Input Index', Int(-1))
+       sb.add_param('Output Index', Int(-1))
+       sb.set_docs('''\
+Selector Block is not implemented! Do not use.
+1 <= Num Inputs/Outputs <= %d'''%MAX_NUM_SOCKETS)      
+       def make(fg, type, num_inputs, num_outputs, vlen, input_index, 
output_index):
+               sh = selector_handler(fg, input_index.parse(), 
output_index.parse())
+               fg.add_callback(sh.set_input_index, input_index)
+               fg.add_callback(sh.set_output_index, output_index)
+               return sh
+       return sb, make
                
\ No newline at end of file

Modified: grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py      
2007-05-25 19:59:03 UTC (rev 5540)
+++ grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py      
2007-05-27 04:35:18 UTC (rev 5541)
@@ -169,7 +169,8 @@
                                ('Head', Misc.Head),                    
                                ('RMS', Misc.RMS),      
                                ('About', Misc.About),
-                               ('Note', Misc.Note),            
+                               ('Note', Misc.Note),    
+                               ('Selector', Misc.Selector),    
                        ]),
                ] 
                





reply via email to

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