]> git.gag.com Git - debian/gnuradio/commitdiff
probe function block
authorjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Wed, 8 Oct 2008 05:18:19 +0000 (05:18 +0000)
committerjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Wed, 8 Oct 2008 05:18:19 +0000 (05:18 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9745 221aa14e-8319-0410-a670-987f0aec2ac5

grc/data/platforms/python/block_tree.xml
grc/data/platforms/python/blocks/Makefile.am
grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml
grc/data/platforms/python/blocks/probe_function.xml [new file with mode: 0644]
grc/src/grc_gnuradio/blks2/__init__.py
grc/src/grc_gnuradio/blks2/probe.py
grc/src/platforms/python/Generator.py
grc/todo.txt

index 5e2d8f50c3300e6a006ec036df056720d68e5b54..4cd1ca219a68c03a02d378278c9644a0ff575442 100644 (file)
                <block>gr_probe_avg_mag_sqrd_x</block>
                <block>gr_probe_density_b</block>
                <block>gr_probe_mpsk_snr_c</block>
+               <block>probe_function</block>
        </cat>
        <cat>
                <name>USRP</name>
index 1e4d3f7fccf04c0e97b556f2b0176db73264b78b..de6792602e7794bf7b1d0c11747e90599f2bc7b1 100644 (file)
@@ -184,6 +184,7 @@ dist_ourdata_DATA = \
        pad_source.xml \
        parameter.xml \
        preferences.xml \
+       probe_function.xml \
        random_source_x.xml \
        trellis_encoder_xx.xml \
        trellis_metrics_x.xml \
index 655eb7c0deaa495dbd02ee60439adbabdf9aa14f..8b427076ad70ad8a3b84c55faccfa8e97c3052c6 100644 (file)
@@ -9,7 +9,7 @@
        <key>gr_probe_mpsk_snr_c</key>
        <import>from grc_gnuradio import blks2 as grc_blks2</import>
        <make>grc_blks2.probe_mpsk_snr_c(
-       type="$type",
+       type=&quot;$type&quot;,
        alpha=$alpha,
        probe_rate=$probe_rate,
 )</make>
diff --git a/grc/data/platforms/python/blocks/probe_function.xml b/grc/data/platforms/python/blocks/probe_function.xml
new file mode 100644 (file)
index 0000000..d468785
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+##Probe Function
+###################################################
+ -->
+<block>
+       <name>Probe Function</name>
+       <key>probe_function</key>
+       <import>from grc_gnuradio import blks2 as grc_blks2</import>
+       <make>grc_blks2.probe_function(
+       probe_callback=self.$(block_id.eval).$(function_name.eval),
+       probe_rate=$probe_rate,
+)</make>
+       <callback>set_probe_rate($probe_rate)</callback>
+       <param>
+               <name>Block ID</name>
+               <key>block_id</key>
+               <value>my_block_0</value>
+               <type>string</type>
+       </param>
+       <param>
+               <name>Function Name</name>
+               <key>function_name</key>
+               <value>get_number</value>
+               <type>string</type>
+       </param>
+       <param>
+               <name>Probe Rate</name>
+               <key>probe_rate</key>
+               <value>10</value>
+               <type>real</type>
+       </param>
+       <source>
+               <name>out</name>
+               <type>float</type>
+       </source>
+       <doc>
+Polls a function of an arbitrary block and writes the value to the output port. \
+The block id is the id of another block in the flow graph. \
+The function name is the name of a function in the said block. \
+The function should take no arguments and return a floating point or integer number.
+       </doc>
+</block>
index a66988d475c9a7fc51786af6303be243fcf19d3f..0e94dbb9827554fe795a3d87893a23aea85ebde4 100644 (file)
@@ -25,4 +25,4 @@ from queue import queue_source_c, queue_source_f, queue_source_i, queue_source_s
 from selector import selector, valve
 from packet import packet_encoder, packet_decoder
 from error_rate import error_rate
-from probe import probe_avg_mag_sqrd_c, probe_avg_mag_sqrd_f, probe_density_b, probe_mpsk_snr_c
+from probe import probe_function, probe_avg_mag_sqrd_c, probe_avg_mag_sqrd_f, probe_density_b, probe_mpsk_snr_c
index 28721422db2c93329acdab9935c39fad515b5542..8db81f057ad3dc8453935cd92cb382b8040e624f 100644 (file)
@@ -24,17 +24,19 @@ import threading
 import numpy
 import time
 
-class _probe_base(gr.hier_block2, threading.Thread):
+#######################################################################################
+## Probe: Function
+#######################################################################################
+class probe_function(gr.hier_block2, threading.Thread):
        """
-       A hier2 block with float output and probe input.
-       The thread polls the prope for values and writes to a message source.
+       The thread polls the function for values and writes to a message source.
        """
 
-       def __init__(self, probe_block, probe_callback, probe_rate):
+       def __init__(self, probe_callback, probe_rate):
                #init hier block
                gr.hier_block2.__init__(
-                       self, 'probe',
-                       gr.io_signature(1, 1, probe_block.input_signature().sizeof_stream_items()[0]),
+                       self, 'probe_function',
+                       gr.io_signature(0, 0, 0),
                        gr.io_signature(1, 1, gr.sizeof_float),
                )
                self._probe_callback = probe_callback
@@ -43,7 +45,6 @@ class _probe_base(gr.hier_block2, threading.Thread):
                message_source = gr.message_source(gr.sizeof_float, 1)
                self._msgq = message_source.msgq()
                #connect
-               self.connect(self, probe_block)
                self.connect(message_source, self)
                #setup thread
                threading.Thread.__init__(self)
@@ -63,6 +64,21 @@ class _probe_base(gr.hier_block2, threading.Thread):
        def set_probe_rate(self, probe_rate):
                self._probe_rate = probe_rate
 
+class _probe_base(gr.hier_block2):
+       def __init__(self, probe_block, probe_callback, probe_rate):
+               #init hier block
+               gr.hier_block2.__init__(
+                       self, 'probe',
+                       gr.io_signature(1, 1, probe_block.input_signature().sizeof_stream_items()[0]),
+                       gr.io_signature(1, 1, gr.sizeof_float),
+               )
+               probe_function_block = probe_function(probe_callback, probe_rate)
+               #forward callbacks
+               self.set_probe_rate = probe_function_block.set_probe_rate
+               #connect
+               self.connect(self, probe_block)
+               self.connect(probe_function_block, self)
+
 #######################################################################################
 ## Probe: Average Magnitude Squared
 #######################################################################################
index bd3d69cc25acec6967530f233e6c4f7d8837e62e..7879fdfc064456d8b16d36fe3ba8c6856a4a972e 100644 (file)
@@ -81,7 +81,8 @@ class Generator(object):
                controls = filter(lambda v: v.get_key().startswith('variable_'), variables)
                #list of blocks not including variables and imports and parameters and disabled
                blocks = sorted(self._flow_graph.get_enabled_blocks(), lambda x, y: cmp(x.get_id(), y.get_id()))
-               blocks = filter(lambda b: b not in (imports + parameters + variables), blocks)
+               probes = filter(lambda b: b.get_key().startswith('probe_'), blocks) #ensure probes are last in the block list
+               blocks = filter(lambda b: b not in (imports + parameters + variables + probes), blocks) + probes
                #list of connections where each endpoint is enabled
                connections = self._flow_graph.get_enabled_connections()
                #list of variable names
index d9025b66831cc4aacf1e00688eb692b7a03bb96b..bce1028eae78d1939e90668db9b68bd27aaca7d2 100644 (file)
@@ -6,6 +6,8 @@
 -controlled step block
 -throttle with sink only (source is nulled)
 -simplify simple usrp
+-numbersink: update wrapper for newer api
+-probe: also non-float outputs
 
 ##################################################
 # Features