commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r5777 - in grc/branches/jblum_work/src: . Elements Gra


From: jblum
Subject: [Commit-gnuradio] r5777 - in grc/branches/jblum_work/src: . Elements Graphics SignalBlockDefs
Date: Sat, 16 Jun 2007 22:25:51 -0600 (MDT)

Author: jblum
Date: 2007-06-16 22:25:50 -0600 (Sat, 16 Jun 2007)
New Revision: 5777

Added:
   grc/branches/jblum_work/src/SignalBlockDefs/Packet.py
Modified:
   grc/branches/jblum_work/src/Colors.py
   grc/branches/jblum_work/src/Elements/GraphicalSocket.py
   grc/branches/jblum_work/src/ExecFlowGraph.py
   grc/branches/jblum_work/src/Graphics/Dialogs.py
   grc/branches/jblum_work/src/SignalBlockDefs/Modulators.py
   grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py
   grc/branches/jblum_work/src/SignalBlockDefs/Sinks.py
Log:
work on packet support

Modified: grc/branches/jblum_work/src/Colors.py
===================================================================
--- grc/branches/jblum_work/src/Colors.py       2007-06-17 00:59:25 UTC (rev 
5776)
+++ grc/branches/jblum_work/src/Colors.py       2007-06-17 04:25:50 UTC (rev 
5777)
@@ -39,6 +39,8 @@
 INT_VECTOR_COLOR_SPEC = '#00CC99'
 SHORT_VECTOR_COLOR_SPEC = '#CCCC33'
 BYTE_VECTOR_COLOR_SPEC = '#CC66CC'
+# misc #
+STRING_COLOR_SPEC = '#FFFFFF'
 
 COLORMAP = gtk.gdk.colormap_get_system()       #create all of the colors
 BACKGROUND_COLOR = COLORMAP.alloc_color('#FFF9FF', True, True) #main window 
background
@@ -58,4 +60,5 @@
 SHORT_VECTOR_COLOR = COLORMAP.alloc_color(SHORT_VECTOR_COLOR_SPEC, True, True) 
#background for shorts (yellowish)
 INT_VECTOR_COLOR = COLORMAP.alloc_color(INT_VECTOR_COLOR_SPEC, True, True)     
#background for ints (greenish)
 BYTE_VECTOR_COLOR = COLORMAP.alloc_color(BYTE_VECTOR_COLOR_SPEC, True, True)   
#background for bytes (purplish)
-
+# misc #
+STRING_COLOR = COLORMAP.alloc_color(STRING_COLOR_SPEC, True, True)     
#background for strings (white)

Modified: grc/branches/jblum_work/src/Elements/GraphicalSocket.py
===================================================================
--- grc/branches/jblum_work/src/Elements/GraphicalSocket.py     2007-06-17 
00:59:25 UTC (rev 5776)
+++ grc/branches/jblum_work/src/Elements/GraphicalSocket.py     2007-06-17 
04:25:50 UTC (rev 5777)
@@ -48,7 +48,9 @@
                        FloatVector().get_type():Colors.FLOAT_VECTOR_COLOR,
                        IntVector().get_type():Colors.INT_VECTOR_COLOR,
                        ShortVector().get_type():Colors.SHORT_VECTOR_COLOR,     
                
-                       ByteVector().get_type():Colors.BYTE_VECTOR_COLOR,       
+                       ByteVector().get_type():Colors.BYTE_VECTOR_COLOR,
+                       # misc #
+                       String().get_type():Colors.STRING_COLOR,        
                }[self.get_data_type().get_type()]
                self._create_labels()           
                #       add the input/output area for each rotation angle       
#       

Modified: grc/branches/jblum_work/src/ExecFlowGraph.py
===================================================================
--- grc/branches/jblum_work/src/ExecFlowGraph.py        2007-06-17 00:59:25 UTC 
(rev 5776)
+++ grc/branches/jblum_work/src/ExecFlowGraph.py        2007-06-17 04:25:50 UTC 
(rev 5777)
@@ -28,6 +28,7 @@
 import os
 from Constants import DEFAULT_FILE_EXTENSION
 from optparse import OptionParser
+from SignalBlockDefs import Packet
 
 
##############################################################################################
 #      Flow Graph Builder
@@ -91,9 +92,13 @@
                        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    
#
-                               (signal_blocks_dict[output_signal_block_id], 
output_socket_index),
-                               (signal_blocks_dict[input_signal_block_id], 
input_socket_index))
+                       input_signal_block = 
signal_blocks_dict[input_signal_block_id]
+                       output_signal_block = 
signal_blocks_dict[output_signal_block_id]
+                       if Packet.is_packet_block(input_signal_block) and 
Packet.is_packet_block(output_signal_block):
+                               
Packet.connect_packet_blocks(output_signal_block, input_signal_block)
+                       else: self.connect(#    use this flow graph's connect 
method    #
+                               (output_signal_block, output_socket_index),
+                               (input_signal_block, input_socket_index))
                                
 
##############################################################################################
 #      Option Parser for running a flow graph

Modified: grc/branches/jblum_work/src/Graphics/Dialogs.py
===================================================================
--- grc/branches/jblum_work/src/Graphics/Dialogs.py     2007-06-17 00:59:25 UTC 
(rev 5776)
+++ grc/branches/jblum_work/src/Graphics/Dialogs.py     2007-06-17 04:25:50 UTC 
(rev 5777)
@@ -163,21 +163,31 @@
                gtk.Dialog.__init__(self, buttons=('gtk-close', 
gtk.RESPONSE_CLOSE))
                self.set_title('Colors')
                self.set_size_request(150, -1)
-               for dt_name, color in (('Complex', Colors.COMPLEX_COLOR_SPEC),
-                                                                               
('Float', Colors.FLOAT_COLOR_SPEC),
-                                                                               
('Int', Colors.INT_COLOR_SPEC),
-                                                                               
('Short', Colors.SHORT_COLOR_SPEC),                                             
                                
-                                                                               
('Byte', Colors.BYTE_COLOR_SPEC),
-                                                                               
#       and for the vectors     #
-                                                                               
('Complex Vector', Colors.COMPLEX_VECTOR_COLOR_SPEC),
-                                                                               
('Float Vector', Colors.FLOAT_VECTOR_COLOR_SPEC),
-                                                                               
('Int Vector', Colors.INT_VECTOR_COLOR_SPEC),
-                                                                               
('Short Vector', Colors.SHORT_VECTOR_COLOR_SPEC),                               
                                                
-                                                                               
('Byte Vector', Colors.BYTE_VECTOR_COLOR_SPEC),):
-                       label = gtk.Label('')
-                       label.set_markup('<span 
background="%s">%s</span>'%(color, dt_name))
-                       label.show()
-                       self.vbox.pack_start(label)
+               markup = ''
+               for color_spec in (
+                       'Regular Types:',
+                       ('Complex', Colors.COMPLEX_COLOR_SPEC),
+                       ('Float', Colors.FLOAT_COLOR_SPEC),
+                       ('Int', Colors.INT_COLOR_SPEC),
+                       ('Short', Colors.SHORT_COLOR_SPEC),                     
                                                        
+                       ('Byte', Colors.BYTE_COLOR_SPEC),
+                       'Vector Types:',
+                       ('Complex Vector', Colors.COMPLEX_VECTOR_COLOR_SPEC),
+                       ('Float Vector', Colors.FLOAT_VECTOR_COLOR_SPEC),
+                       ('Int Vector', Colors.INT_VECTOR_COLOR_SPEC),
+                       ('Short Vector', Colors.SHORT_VECTOR_COLOR_SPEC),       
                                                                        
+                       ('Byte Vector', Colors.BYTE_VECTOR_COLOR_SPEC),
+                       'Misc:',
+                       ('String/Packet', Colors.STRING_COLOR_SPEC),
+               ):
+                       if type(color_spec) == type(str()): markup = 
'%s\n\n<b>%s</b>'%(markup, color_spec)
+                       else:   
+                               tag,spec = color_spec                           
+                               markup = '%s\n<span 
background="%s">%s</span>'%(markup, spec, tag)
+               label = gtk.Label('')
+               label.set_markup(markup[1:]+'\n')       #strip 1st newline, 
append newline
+               label.show()
+               self.vbox.pack_start(label)
                self.run()
                self.destroy()                  
                        
@@ -188,27 +198,31 @@
                """HotKeysDialog constructor."""
                gtk.Dialog.__init__(self, buttons=('gtk-close', 
gtk.RESPONSE_CLOSE))
                self.set_title('Hot Keys')
-               for action, hotkey in (('New Flow Graph', 'Ctrl + n'),
-                                                                               
('Open Flow Graph', 'Ctrl + o'),
-                                                                               
('Save Flow Graph', 'Ctrl + s'),
-                                                                               
('Undo Change', 'Ctrl + z'),
-                                                                               
('Redo Change', 'Ctrl + y'),
-                                                                               
('Redo Change', 'Ctrl + Z'),
-                                                                               
('Delete Block', 'Delete'),
-                                                                               
('Rotate Block', 'Right'),
-                                                                               
('Rotate Block', 'Left'),
-                                                                               
('Modify Data Type', 'Up'),
-                                                                               
('Modify Data Type', 'Down'),
-                                                                               
('Add a Socket', '+'),
-                                                                               
('Remove a Socket', '-'),
-                                                                               
('Close GraphicalParams Dialog', 'Esc'),
-                                                                               
('Flow Graph Run', 'F5'),
-                                                                               
('Flow Graph Stop', 'F7'),
-                                                                               
('Screen Shot', 'PrintScreen'),):
-                       label = gtk.Label('')
-                       label.set_markup('<b>%s:</b> %s'%(action, hotkey))
-                       label.show()
-                       self.vbox.pack_start(label)
+               markup = ''
+               for action, hotkey in (
+                       ('New Flow Graph', 'Ctrl + n'),
+                       ('Open Flow Graph', 'Ctrl + o'),
+                       ('Save Flow Graph', 'Ctrl + s'),
+                       ('Undo Change', 'Ctrl + z'),
+                       ('Redo Change', 'Ctrl + y'),
+                       ('Redo Change', 'Ctrl + Z'),
+                       ('Delete Block', 'Delete'),
+                       ('Rotate Block', 'Right'),
+                       ('Rotate Block', 'Left'),
+                       ('Modify Data Type', 'Up'),
+                       ('Modify Data Type', 'Down'),
+                       ('Add a Socket', '+'),
+                       ('Remove a Socket', '-'),
+                       ('Close GraphicalParams Dialog', 'Esc'),
+                       ('Flow Graph Run', 'F5'),
+                       ('Flow Graph Stop', 'F7'),
+                       ('Screen Shot', 'PrintScreen'),
+               ):
+                       markup = '%s\n<b>%s:</b> %s'%(markup, action, hotkey)
+               label = gtk.Label('')
+               label.set_markup(markup+'\n')   #append newline
+               label.show()
+               self.vbox.pack_start(label)
                self.run()
                self.destroy()          
                

Modified: grc/branches/jblum_work/src/SignalBlockDefs/Modulators.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Modulators.py   2007-06-17 
00:59:25 UTC (rev 5776)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Modulators.py   2007-06-17 
04:25:50 UTC (rev 5777)
@@ -23,21 +23,21 @@
 from DataTypes import *
 from gnuradio import gr
 
-def FrequencyModulation(sb):
+def FrequencyMod(sb):
        fcn = gr.frequency_modulator_fc
        sb.add_input_socket('in', Float())
        sb.add_output_socket('out', Complex())  
        sb.add_param('Sensitivity', Float(.01)) 
        return sb, lambda fg, sensitivity: fcn(sensitivity.parse())
        
-def PhaseModulation(sb):
+def PhaseMod(sb):
        fcn = gr.phase_modulator_fc
        sb.add_input_socket('in', Float())
        sb.add_output_socket('out', Complex())  
        sb.add_param('Sensitivity', Float(.01)) 
        return sb, lambda fg, sensitivity: fcn(sensitivity.parse())
        
-def QuadratureDemodulation(sb):
+def QuadratureDemod(sb):
        fcn = gr.quadrature_demod_cf
        sb.add_input_socket('in', Complex())
        sb.add_output_socket('out', Float())    

Added: grc/branches/jblum_work/src/SignalBlockDefs/Packet.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Packet.py                       
        (rev 0)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Packet.py       2007-06-17 
04:25:50 UTC (rev 5777)
@@ -0,0 +1,164 @@
+"""
+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
+"""
address@hidden SignalBlockDefs.Packet
+#Support for the gr packet framework.
address@hidden Josh Blum
+
+from DataTypes import *
+from gnuradio import gr,blks
+from SignalBlockConstants import all_choices
+
+packet_attr = 'packet based'
+packet_mod = 'packet mod'
+packet_demod = 'packet demod'
+packet_to_stream = 'packet to stream'
+stream_to_packet = 'stream to packet'
+
+def is_packet_block(block):
+       """!
+       Is the block a packet based block?
+       @param block the gr block
+       @return true if the block is packet based
+       """
+       return hasattr(block, packet_attr)
+       
+def connect_packet_blocks(output_block, input_block):
+       """!
+       Connect two packet based blocks.
+       Use callback functions in combination with message queues and threads 
+       to transfer data between input and output blocks.
+       @param output_block message sink/packet demod
+       @param input_block message source/packet mod
+       """
+       output_attr = getattr(output_block, packet_attr)
+       input_attr = getattr(input_block, packet_attr)
+       if output_attr == packet_demod and input_attr == packet_mod:    
+               output_block._watcher.callback = lambda ok, payload: 
input_block.send_pkt(payload)
+       #elif output_attr == packet_demod and input_attr == packet to stream:
+               #output_block._watcher.callback = lambda ok, payload: 
input_block.msgq().
+
+#######################################################################################
+##     Packet Modulator and Demodulator
+#######################################################################################
+
+def PacketMod(sb):
+       fcn = blks.mod_pkts
+       sb.add_input_socket('pin', String(), optional=True)             #packet 
input
+       sb.add_output_socket('out', Byte())
+       sb.add_param('Modulator Type', Enum([
+               ('GMSK', blks.gmsk_mod),
+               ('DBPSK', blks.dbpsk_mod),
+               ('DQPSK', blks.dqpsk_mod),
+               ('D8PSK', blks.d8psk_mod),
+               ('QAM 8', blks.qam8_mod),
+               ('QAM 64', blks.qam64_mod),
+               ('QAM 256', blks.qam256_mod),
+       ]), type=True)
+       sb.add_param('Samples/Symbol', Int(2, min=1))
+       sb.add_param('Access Code', String('', max=64))
+       sb.add_param('Message Queue Limit', Int(2, min=1))
+       sb.add_param('Pad for USRP', Bool(true='Yes', false='No', default=True))
+       sb.add_param('Use Whitener Offset', Bool(true='Yes', false='No', 
default=False))
+       sb.set_docs('''\
+Send packets to the modulator.
+
+Access code/sync vector: string of 1's and 0's between 1 and 64 long. Leave 
blank for default.
+Msgq limit: maximum number of messages in message queue.
+Pad for USRP: If true, packets are padded such that they end up a multiple of 
128 samples.
+Use whitener offset: If true, start of whitener XOR string is incremented each 
packet.
+''')
+       def make(fg, mod_type, samps_per_symbol, access_code, msgq_limit, 
pad_for_usrp, use_whitener_offset):
+               access_code = access_code.parse()
+               if access_code == '': access_code = None        #access code 
should be None if blank
+               #dummy modulator with access functions          
+               modulator = gr.skiphead(Byte().get_num_bytes(), 0)              
#skip nothing
+               modulator.samples_per_symbol = lambda: samps_per_symbol.parse()
+               modulator.bits_per_symbol = lambda: 
mod_type.parse().bits_per_symbol()
+               block = fcn(
+                       fg=fg, 
+                       modulator=modulator, 
+                       access_code=access_code, 
+                       msgq_limit=msgq_limit.parse(), 
+                       pad_for_usrp=pad_for_usrp.parse(), 
+                       use_whitener_offset=use_whitener_offset.parse(),
+               )       #build packet modulator
+               setattr(block, packet_attr, packet_mod) #add packet attr
+               return block
+       return sb, make
+       
+def PacketDemod(sb):
+       fcn = blks.demod_pkts
+       sb.add_output_socket('pout', String(), optional=True)           #packet 
output
+       sb.add_input_socket('in', Byte())       
+       sb.add_param('Access Code', String('', max=64))
+       sb.add_param('Threshold', Int(-1))
+       sb.set_docs('''\
+Receive packets from the demodulator.
+
+Access code/sync vector: string of 1's and 0's between 1 and 64 long. Leave 
blank for default.
+Threshold: detect access_code with up to threshold bits wrong.
+''')
+       def make(fg, access_code, threshold):
+               access_code = access_code.parse()
+               if access_code == '': access_code = None        #access code 
should be None if blank
+               #dummy demodulator      
+               demodulator = gr.skiphead(Byte().get_num_bytes(), 0)            
#skip nothing   
+               block = fcn(
+                       fg=fg, 
+                       demodulator=demodulator,
+                       access_code=access_code, 
+                       callback=None,  #the callback will be set later
+                       threshold=threshold.parse(),
+               )       #build packet demodulator
+               setattr(block, packet_attr, packet_demod)       #add packet attr
+               return block
+       return sb, make
+
+#######################################################################################
+##     Stream <-> Packet
+#######################################################################################
+
+def StreamToPacket(sb):
+       fcn = gr.message_sink
+       type = Enum(all_choices, 1)
+       sb.add_input_socket('in', Variable(type))
+       sb.add_output_socket('pout', String())
+       sb.add_param('Type', type, False, type=True)
+       sb.add_param('Message Queue Limit', Int(2, min=1))
+       def make(fg, type, msgq_limit):
+               msgq = gr.msg_queue(msgq_limit.parse())
+               block = gr.message_sink(type.parse().get_num_bytes(), msgq, 
True)
+               block.msgq = lambda: msgq
+               setattr(block, packet_attr, stream_to_packet)   #add packet attr
+               return block
+       return sb, make
+       
+def PacketToStream(sb):
+       fcn = gr.message_source
+       type = Enum(all_choices, 1)
+       sb.add_input_socket('pin', String())
+       sb.add_output_socket('out', Variable(type)())
+       sb.add_param('Type', type, False, type=True)
+       sb.add_param('Message Queue Limit', Int(2, min=1))
+       def make(fg, type, msgq_limit):
+               block = gr.message_sink(type.parse().get_num_bytes(), 
msgq_limit.parse())
+               setattr(block, packet_attr, packet_to_stream)   #add packet attr
+               return block
+       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-06-17 00:59:25 UTC (rev 5776)
+++ grc/branches/jblum_work/src/SignalBlockDefs/SignalBlockTree.py      
2007-06-17 04:25:50 UTC (rev 5777)
@@ -32,6 +32,7 @@
 import USRP
 import Coders
 import Trellis
+import Packet
 
 ##A categorized list of all signal blocks
 SB_TREE = [
@@ -132,23 +133,23 @@
                                ('IFFT', Filters.IFFT),
                        ]),
                        ('Modulators', [                        
-                               ('Frequency Modulation', 
Modulators.FrequencyModulation),
-                               ('Phase Modulation', 
Modulators.PhaseModulation),
-                               ('Quadrature Demodulation', 
Modulators.QuadratureDemodulation),
+                               ('Frequency Modulator', 
Modulators.FrequencyMod),
+                               ('Phase Modulator', Modulators.PhaseMod),
+                               ('Quadrature Demodulator', 
Modulators.QuadratureDemod),
                                ('Costas Loop', Modulators.CostasLoop),
                                ('Phase Locked Loop', Modulators.PLL),
                                ('WFM Receive', Modulators.WFMReceive),         
        
                                ('WFM Transmit', Modulators.WFMTransmit),       
                                ('NBFM Receive', Modulators.NBFMReceive),       
                
                                ('NBFM Transmit', Modulators.NBFMTransmit),     
-                               ('AM Demodulation', Modulators.AMDemod),
-                               ('FM Demodulation', Modulators.FMDemod),
-                               ('PSK Modulation', Modulators.PSKMod),
-                               ('PSK Demodulation', Modulators.PSKDemod),
-                               ('GMSK Modulation', Modulators.GMSKMod),
-                               ('GMSK Demodulation', Modulators.GMSKDemod),
-                               ('QAM Modulation', Modulators.QAMMod),
-                               ('QAM Demodulation', Modulators.QAMDemod),
+                               ('AM Demodulator', Modulators.AMDemod),
+                               ('FM Demodulator', Modulators.FMDemod),
+                               ('PSK Modulator', Modulators.PSKMod),
+                               ('PSK Demodulator', Modulators.PSKDemod),
+                               ('GMSK Modulator', Modulators.GMSKMod),
+                               ('GMSK Demodulator', Modulators.GMSKDemod),
+                               ('QAM Modulator', Modulators.QAMMod),
+                               ('QAM Demodulator', Modulators.QAMDemod),
                        ]),
                        ('Coders', [
                                ('Constellation Decoder', 
Coders.ConstellationDecoder),                         
@@ -167,6 +168,12 @@
                                ('Interleaver', Trellis.Interleaver),
                                ('Deinterleaver', Trellis.Deinterleaver),
                        ]),
+                       ('Packet', [    
+                               ('Packet Modulator', Packet.PacketMod),
+                               ('Packet Demodulator', Packet.PacketDemod),
+                               ('Stream to Packet', Packet.StreamToPacket),
+                               ('Packet to Stream', Packet.PacketToStream),
+                       ]),
                        ('Misc', [      
                                ('Throttle', Misc.Throttle),
                                ('Head', Misc.Head),    

Modified: grc/branches/jblum_work/src/SignalBlockDefs/Sinks.py
===================================================================
--- grc/branches/jblum_work/src/SignalBlockDefs/Sinks.py        2007-06-17 
00:59:25 UTC (rev 5776)
+++ grc/branches/jblum_work/src/SignalBlockDefs/Sinks.py        2007-06-17 
04:25:50 UTC (rev 5777)
@@ -86,20 +86,30 @@
 import numpy
        
 class VariableSinkThread(threading.Thread):
-       """ This thread will read the vector sink at the sampling rate,
-               write the numeric value back to the variable,
-               and re-parse the flow graph's callbacks.        """
+       """
+       This thread will read the vector sink,
+       write the numeric value back to the variable,
+       and re-parse the flow graph's callbacks.
+       """
        def __init__(self, fg, var_key, msgq):
-               """ Create a new variable sink thread.  """
+               """!
+               VariableSinkThread constructor.
+               @param fg the gr flow graph
+               @param var_key the variable key
+               @param msgq the message queue
+               """
                self.fg = fg
                self.var_key = var_key
                self.msgq = msgq
                threading.Thread.__init__(self)
+               self.start()
                print 'Created variable sink thread for variable "%s"'%var_key
                                
        def run(self):
-               """ In a endless while loop: read the vector sink,
-                       write to the variable, and parse the callbacks. """
+               """
+               In a endless while loop: read the vector sink,
+               write to the variable, and parse the callbacks.
+               """
                while True:
                        try:            
                                msg = self.msgq.delete_head()  # blocking read 
of message queue
@@ -132,16 +142,16 @@
        sb.add_param('Type', type, False, type=True)
        sb.add_param('Variable', VariableKeySelector()) 
        sb.add_param('Samp Rate', Float(default_samp_rate))
+       sb.add_param('Message Queue Limit', Int(2, min=1))
        sb.set_docs('''\
 A thread reads a message sink and writes to the variable. \
 The variable cannot have a range. \
 The variable must be specified using its name without the "$" symbol. \
 The variable sink has a throttle automatically attatched to it at runtime to 
save the CPU.''') 
-       def make(fg, type, var_key, samp_rate):
-               msgq = gr.msg_queue(1)  #msg size of 1
+       def make(fg, type, var_key, samp_rate, msgq_limit):
+               msgq = gr.msg_queue(msgq_limit.parse())
                block = gr.message_sink(type.parse().get_num_bytes(), msgq, 
True)
                var_sink_thread = VariableSinkThread(fg, var_key.parse(), msgq)
-               var_sink_thread.start() #the thread begins
                th = gr.throttle(type.parse().get_num_bytes(), 
samp_rate.parse())
                fg.connect(th, block)
                return th





reply via email to

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