summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grc/data/platforms/python/block_tree.xml1
-rw-r--r--grc/data/platforms/python/blocks/Makefile.am1
-rw-r--r--grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml2
-rw-r--r--grc/data/platforms/python/blocks/probe_function.xml44
-rw-r--r--grc/src/grc_gnuradio/blks2/__init__.py2
-rw-r--r--grc/src/grc_gnuradio/blks2/probe.py30
-rw-r--r--grc/src/platforms/python/Generator.py3
-rw-r--r--grc/todo.txt2
8 files changed, 75 insertions, 10 deletions
diff --git a/grc/data/platforms/python/block_tree.xml b/grc/data/platforms/python/block_tree.xml
index 5e2d8f50c..4cd1ca219 100644
--- a/grc/data/platforms/python/block_tree.xml
+++ b/grc/data/platforms/python/block_tree.xml
@@ -241,6 +241,7 @@
<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>
diff --git a/grc/data/platforms/python/blocks/Makefile.am b/grc/data/platforms/python/blocks/Makefile.am
index 1e4d3f7fc..de6792602 100644
--- a/grc/data/platforms/python/blocks/Makefile.am
+++ b/grc/data/platforms/python/blocks/Makefile.am
@@ -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 \
diff --git a/grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml b/grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml
index 655eb7c0d..8b427076a 100644
--- a/grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml
+++ b/grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml
@@ -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
index 000000000..d46878526
--- /dev/null
+++ b/grc/data/platforms/python/blocks/probe_function.xml
@@ -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>
diff --git a/grc/src/grc_gnuradio/blks2/__init__.py b/grc/src/grc_gnuradio/blks2/__init__.py
index a66988d47..0e94dbb98 100644
--- a/grc/src/grc_gnuradio/blks2/__init__.py
+++ b/grc/src/grc_gnuradio/blks2/__init__.py
@@ -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
diff --git a/grc/src/grc_gnuradio/blks2/probe.py b/grc/src/grc_gnuradio/blks2/probe.py
index 28721422d..8db81f057 100644
--- a/grc/src/grc_gnuradio/blks2/probe.py
+++ b/grc/src/grc_gnuradio/blks2/probe.py
@@ -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
#######################################################################################
diff --git a/grc/src/platforms/python/Generator.py b/grc/src/platforms/python/Generator.py
index bd3d69cc2..7879fdfc0 100644
--- a/grc/src/platforms/python/Generator.py
+++ b/grc/src/platforms/python/Generator.py
@@ -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
diff --git a/grc/todo.txt b/grc/todo.txt
index d9025b668..bce1028ea 100644
--- a/grc/todo.txt
+++ b/grc/todo.txt
@@ -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