diff options
Diffstat (limited to 'grc/src')
-rw-r--r-- | grc/src/grc_gnuradio/blks2/__init__.py | 2 | ||||
-rw-r--r-- | grc/src/grc_gnuradio/blks2/probe.py | 30 | ||||
-rw-r--r-- | grc/src/platforms/python/Generator.py | 3 |
3 files changed, 26 insertions, 9 deletions
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 |