this time commit the file changes
authorJosh Blum <josh@joshknows.com>
Fri, 14 Aug 2009 06:59:06 +0000 (23:59 -0700)
committerJosh Blum <josh@joshknows.com>
Fri, 14 Aug 2009 06:59:06 +0000 (23:59 -0700)
grc/blocks/Makefile.am
grc/blocks/block_tree.xml
grc/blocks/gr_message_sink.xml
grc/blocks/gr_message_source.xml
grc/python/Block.py
grc/python/Connection.py
grc/python/Constants.py
grc/python/Generator.py
grc/python/Port.py
grc/python/block.dtd
grc/python/flow_graph.tmpl

index 025c261f4fe420ca3cadddd8c5704591bce7e6ec..fbd8f4bb4dace7e169f4a3f640691815e703c1f3 100644 (file)
@@ -123,6 +123,8 @@ dist_ourdata_DATA = \
        gr_kludge_copy.xml \
        gr_map_bb.xml \
        gr_max_xx.xml \
+       gr_message_sink.xml \
+       gr_message_source.xml \
        gr_moving_average_xx.xml \
        gr_mpsk_receiver_cc.xml \
        gr_mpsk_sync_cc.xml \
index 9eda2fdcf80fa113638e63dcba8fc9d92c1bf627..2cedb45a2a7dbb376f54a7cc0ccf53b24b9a1b9c 100644 (file)
@@ -20,6 +20,7 @@
                <block>gr_udp_source</block>
                <block>audio_source</block>
                <block>gr_wavfile_source</block>
+               <block>gr_message_source</block>
                <block>pad_source</block>
        </cat>
        <cat>
@@ -32,6 +33,7 @@
                <block>gr_udp_sink</block>
                <block>audio_sink</block>
                <block>gr_wavfile_sink</block>
+               <block>gr_message_sink</block>
                <block>pad_sink</block>
        </cat>
        <cat>
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..76537f2833e56e74e9d849c8574a9c0eb29b8601 100644 (file)
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Message Sink (the source port is a message)
+###################################################
+ -->
+<block>
+       <name>Message Sink</name>
+       <key>gr_message_sink</key>
+       <import>from gnuradio import gr</import>
+       <make>gr.message_sink($type.size*$vlen, $(id)_msgq, $dont_block)</make>
+       <param>
+               <name>Input Type</name>
+               <key>type</key>
+               <type>enum</type>
+               <option>
+                       <name>Complex</name>
+                       <key>complex</key>
+                       <opt>size:gr.sizeof_gr_complex</opt>
+               </option>
+               <option>
+                       <name>Float</name>
+                       <key>float</key>
+                       <opt>size:gr.sizeof_float</opt>
+               </option>
+               <option>
+                       <name>Int</name>
+                       <key>int</key>
+                       <opt>size:gr.sizeof_int</opt>
+               </option>
+               <option>
+                       <name>Short</name>
+                       <key>short</key>
+                       <opt>size:gr.sizeof_short</opt>
+               </option>
+               <option>
+                       <name>Byte</name>
+                       <key>byte</key>
+                       <opt>size:gr.sizeof_char</opt>
+               </option>
+       </param>
+       <param>
+               <name>Don't Block</name>
+               <key>dont_block</key>
+               <value>False</value>
+               <type>enum</type>
+               <option>
+                       <name>Don't Block</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>Block</name>
+                       <key>False</key>
+               </option>
+       </param>
+       <param>
+               <name>Vec Length</name>
+               <key>vlen</key>
+               <value>1</value>
+               <type>int</type>
+       </param>
+       <check>$vlen &gt; 0</check>
+       <sink>
+               <name>in</name>
+               <type>$type</type>
+               <vlen>$vlen</vlen>
+       </sink>
+       <source>
+               <name>out</name>
+               <type>msg</type>
+       </source>
+</block>
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..44378ae83fc976527ca8468d9f75dfdcb7089db5 100644 (file)
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Message Source (the sink port is a message)
+###################################################
+ -->
+<block>
+       <name>Message Source</name>
+       <key>gr_message_source</key>
+       <import>from gnuradio import gr</import>
+       <make>gr.message_source($type.size*$vlen, $(id)_msgq)</make>
+       <param>
+               <name>Output Type</name>
+               <key>type</key>
+               <type>enum</type>
+               <option>
+                       <name>Complex</name>
+                       <key>complex</key>
+                       <opt>size:gr.sizeof_gr_complex</opt>
+               </option>
+               <option>
+                       <name>Float</name>
+                       <key>float</key>
+                       <opt>size:gr.sizeof_float</opt>
+               </option>
+               <option>
+                       <name>Int</name>
+                       <key>int</key>
+                       <opt>size:gr.sizeof_int</opt>
+               </option>
+               <option>
+                       <name>Short</name>
+                       <key>short</key>
+                       <opt>size:gr.sizeof_short</opt>
+               </option>
+               <option>
+                       <name>Byte</name>
+                       <key>byte</key>
+                       <opt>size:gr.sizeof_char</opt>
+               </option>
+       </param>
+       <param>
+               <name>Vec Length</name>
+               <key>vlen</key>
+               <value>1</value>
+               <type>int</type>
+       </param>
+       <check>$vlen &gt; 0</check>
+       <sink>
+               <name>in</name>
+               <type>msg</type>
+       </sink>
+       <source>
+               <name>out</name>
+               <type>$type</type>
+               <vlen>$vlen</vlen>
+       </source>
+</block>
index 957fee18ef123aea408a7c5762c41a3121f22011..6693f6f86bbaa6d35a18ee611d34ce3a22bf8177 100644 (file)
@@ -70,6 +70,8 @@ class Block(_Block):
                        (self._sources, self.get_parent().get_parent().Source),
                        (self._sinks, self.get_parent().get_parent().Sink),
                ):
+                       #TODO #FIXME we want to filter out msg ports and run the regular code below this line
+                       if any([port.get_type() == 'msg' for port in ports.values()]): continue
                        #how many ports?
                        num_ports = len(ports)
                        #do nothing for 0 ports
index d8a894bb176a97556bde92b6f572fb680033567a..5eba9f24dd839ed0b6bbf65427bc4f5a2cd02475 100644 (file)
@@ -21,6 +21,9 @@ from .. base.Connection import Connection as _Connection
 
 class Connection(_Connection):
 
+       def is_msg(self):
+               return self.get_source().get_type() == self.get_sink().get_type() == 'msg'
+
        def validate(self):
                """
                Validate the connections.
index 2f629d1bf4e5124429869ba8cd00aca8aeb6ee56..439a524209da7277526f81b1b0f6f92194345c0c 100644 (file)
@@ -61,4 +61,4 @@ SHORT_VECTOR_COLOR_SPEC = '#CCCC33'
 BYTE_VECTOR_COLOR_SPEC = '#CC66CC'
 ID_COLOR_SPEC = '#DDDDDD'
 WILDCARD_COLOR_SPEC = '#FFFFFF'
-MSG_COLOR_SPEC = '#FF6600'
+MSG_COLOR_SPEC = '#777777'
index 33be4a72615e8c6a053e6a87f8de76dd8a75029f..ed7995716f1ecde6e25c5b433703f8708216c5ca 100644 (file)
@@ -98,7 +98,8 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''')
                #list of regular blocks (all blocks minus the special ones)
                blocks = filter(lambda b: b not in (imports + parameters + variables + probes + notebooks), blocks) + probes
                #list of connections where each endpoint is enabled
-               connections = self._flow_graph.get_enabled_connections()
+               connections = filter(lambda c: not c.is_msg(), self._flow_graph.get_enabled_connections())
+               messages = filter(lambda c: c.is_msg(), self._flow_graph.get_enabled_connections())
                #list of variable names
                var_ids = [var.get_id() for var in parameters + variables]
                #prepend self.
@@ -124,6 +125,7 @@ Add a Misc->Throttle block to your flow graph to avoid CPU congestion.''')
                        'parameters': parameters,
                        'blocks': blocks,
                        'connections': connections,
+                       'messages': messages,
                        'generate_options': self._generate_options,
                        'var_id2cbs': var_id2cbs,
                }
index c01884cc3dbfbcb25862bf63a867e3f0b05e50ea..14adc0618ee4f3b7f17d3d17f4be15e1d6b209d8 100644 (file)
@@ -105,10 +105,11 @@ class Source(Port):
 
        def __init__(self, block, n):
                self._n = n #save n
-               if n['type'] != 'msg': #key is port index
+               if n['type'] == 'msg': n['key'] = 'msg'
+               else:
                        n['key'] = str(block._source_count)
                        block._source_count = block._source_count + 1
-                       Port.__init__(self, block, n)
+               Port.__init__(self, block, n)
 
        def __del__(self):
                self.get_parent()._source_count = self.get_parent()._source_count - 1
@@ -117,14 +118,14 @@ class Sink(Port):
 
        def __init__(self, block, n):
                self._n = n #save n
-               if n['type'] != 'msg': #key is port index
+               if n['type'] == 'msg': n['key'] = 'msg'
+               else:
                        n['key'] = str(block._sink_count)
                        block._sink_count = block._sink_count + 1
-                       Port.__init__(self, block, n)
+               Port.__init__(self, block, n)
 
        def __del__(self):
                self.get_parent()._sink_count = self.get_parent()._sink_count - 1
 
-#TODO merge source and sink classes into port class
-#TODO check that key is only defined if and only if type is message
-#TODO check that nports is undefined when type is message 
+#TODO check that nports and vlen is undefined when type is message
+#TODO only allow up to one port of type msg
index 8681d1255e930e13d9c09972e4a0d88b327c8f51..7c6c398114e818c46cf11544842e58712c9601f3 100644 (file)
@@ -31,8 +31,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  -->
 <!ELEMENT param (name, key, value?, type, hide?, option*)>
 <!ELEMENT option (name, key, opt*)>
-<!ELEMENT sink (name, key?, type, vlen?, nports?, optional?)>
-<!ELEMENT source (name, key?, type, vlen?, nports?, optional?)>
+<!ELEMENT sink (name, type, vlen?, nports?, optional?)>
+<!ELEMENT source (name, type, vlen?, nports?, optional?)>
 <!--
        Bottom level elements.
        Character data only.
index b537c43e2993707cb17f3b0ef24f5c5f445ab637..df346dd165567002a34fcfbcd2787818ef43cbea 100644 (file)
@@ -10,6 +10,7 @@
 ##@param parameters the paramater blocks
 ##@param blocks the signal blocks
 ##@param connections the connections
+##@param messages the msg type connections
 ##@param generate_options the type of flow graph
 ##@param var_id2cbs variable id map to callback strings
 ########################################################
@@ -125,6 +126,18 @@ class $(class_name)(gr.hier_block2):
                $indent($ctrl.get_make())
 #end for
 ########################################################
+##Create Message Queues
+########################################################
+#if $messages
+
+               $DIVIDER
+               # Message Queues
+               $DIVIDER
+#end if
+#for $msg in $messages
+               $(msg.get_source().get_parent().get_id())_msgq = $(msg.get_sink().get_parent().get_id())_msgq = gr.msg_queue(2)
+#end for
+########################################################
 ##Create Blocks
 ########################################################
 #if $blocks