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_avg_mag_sqrd_x.xml30
-rw-r--r--grc/data/platforms/python/blocks/gr_probe_density_b.xml28
-rw-r--r--grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml48
-rw-r--r--grc/data/platforms/python/blocks/gr_probe_signal_f.xml31
-rw-r--r--grc/data/platforms/python/blocks/wxgui_numbersink2.xml2
-rw-r--r--grc/src/grc_gnuradio/blks2/Makefile.am1
-rw-r--r--grc/src/grc_gnuradio/blks2/__init__.py1
-rw-r--r--grc/src/grc_gnuradio/blks2/probe.py107
-rw-r--r--grc/src/grc_gnuradio/blks2/queue.py2
-rw-r--r--grc/src/grc_gnuradio/blks2/selector.py1
-rw-r--r--grc/todo.txt7
13 files changed, 177 insertions, 83 deletions
diff --git a/grc/data/platforms/python/block_tree.xml b/grc/data/platforms/python/block_tree.xml
index a234001d8..5e2d8f50c 100644
--- a/grc/data/platforms/python/block_tree.xml
+++ b/grc/data/platforms/python/block_tree.xml
@@ -241,7 +241,6 @@
<block>gr_probe_avg_mag_sqrd_x</block>
<block>gr_probe_density_b</block>
<block>gr_probe_mpsk_snr_c</block>
- <block>gr_probe_signal_f</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 2d4eec56c..1e4d3f7fc 100644
--- a/grc/data/platforms/python/blocks/Makefile.am
+++ b/grc/data/platforms/python/blocks/Makefile.am
@@ -141,7 +141,6 @@ dist_ourdata_DATA = \
gr_probe_avg_mag_sqrd_x.xml \
gr_probe_density_b.xml \
gr_probe_mpsk_snr_c.xml \
- gr_probe_signal_f.xml \
gr_pwr_squelch_xx.xml \
gr_quadrature_demod_cf.xml \
gr_rational_resampler_base_xxx.xml \
diff --git a/grc/data/platforms/python/blocks/gr_probe_avg_mag_sqrd_x.xml b/grc/data/platforms/python/blocks/gr_probe_avg_mag_sqrd_x.xml
index cbd8446cd..eb855956a 100644
--- a/grc/data/platforms/python/blocks/gr_probe_avg_mag_sqrd_x.xml
+++ b/grc/data/platforms/python/blocks/gr_probe_avg_mag_sqrd_x.xml
@@ -7,19 +7,15 @@
<block>
<name>Probe Avg Mag^2</name>
<key>gr_probe_avg_mag_sqrd_x</key>
- <import>from gnuradio import gr</import>
- <import>import threading</import>
- <import>import time</import>
- <make>gr.probe_avg_mag_sqrd_$(type)($threshold, $alpha)
-def _$(id)_run():
- while True:
- time.sleep($update_interval)
- print "$(id) Level:", self.$(id).level()
-_$(id)_thread = threading.Thread(target=_$(id)_run)
-_$(id)_thread.setDaemon(True)
-_$(id)_thread.start()</make>
+ <import>from grc_gnuradio import blks2 as grc_blks2</import>
+ <make>grc_blks2.probe_avg_mag_sqrd_$(type)(
+ threshold=$threshold,
+ alpha=$alpha,
+ probe_rate=$probe_rate,
+)</make>
<callback>set_alpha($alpha)</callback>
<callback>set_threshold($threshold)</callback>
+ <callback>set_probe_rate($probe_rate)</callback>
<param>
<name>Type</name>
<key>type</key>
@@ -38,21 +34,27 @@ _$(id)_thread.start()</make>
<param>
<name>Threshold (dB)</name>
<key>threshold</key>
+ <value>0</value>
<type>real</type>
</param>
<param>
<name>Alpha</name>
<key>alpha</key>
+ <value>1</value>
<type>real</type>
</param>
<param>
- <name>Update Interval (s)</name>
- <key>update_interval</key>
- <value>1.0</value>
+ <name>Probe Rate</name>
+ <key>probe_rate</key>
+ <value>10</value>
<type>real</type>
</param>
<sink>
<name>in</name>
<type>$type.input</type>
</sink>
+ <source>
+ <name>out</name>
+ <type>float</type>
+ </source>
</block>
diff --git a/grc/data/platforms/python/blocks/gr_probe_density_b.xml b/grc/data/platforms/python/blocks/gr_probe_density_b.xml
index 4c5b9e2fa..74d3b0a2b 100644
--- a/grc/data/platforms/python/blocks/gr_probe_density_b.xml
+++ b/grc/data/platforms/python/blocks/gr_probe_density_b.xml
@@ -7,31 +7,31 @@
<block>
<name>Probe Density</name>
<key>gr_probe_density_b</key>
- <import>from gnuradio import gr</import>
- <import>import threading</import>
- <import>import time</import>
- <make>gr.probe_density_b($alpha)
-def _$(id)_run():
- while True:
- time.sleep($update_interval)
- print "$(id) Density:", self.$(id).density()
-_$(id)_thread = threading.Thread(target=_$(id)_run)
-_$(id)_thread.setDaemon(True)
-_$(id)_thread.start()</make>
+ <import>from grc_gnuradio import blks2 as grc_blks2</import>
+ <make>grc_blks2.probe_density_b(
+ alpha=$alpha,
+ probe_rate=$probe_rate,
+)</make>
<callback>set_alpha($alpha)</callback>
+ <callback>set_probe_rate($probe_rate)</callback>
<param>
<name>Alpha</name>
<key>alpha</key>
+ <value>1</value>
<type>real</type>
</param>
<param>
- <name>Update Interval (s)</name>
- <key>update_interval</key>
- <value>1.0</value>
+ <name>Probe Rate</name>
+ <key>probe_rate</key>
+ <value>10</value>
<type>real</type>
</param>
<sink>
<name>in</name>
<type>byte</type>
</sink>
+ <source>
+ <name>out</name>
+ <type>float</type>
+ </source>
</block>
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 ec80d092d..655eb7c0d 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
@@ -7,33 +7,49 @@
<block>
<name>Probe MPSK SNR</name>
<key>gr_probe_mpsk_snr_c</key>
- <import>from gnuradio import gr</import>
- <import>import threading</import>
- <import>import time</import>
- <make>gr.probe_mpsk_snr_c($alpha)
-def _$(id)_run():
- while True:
- time.sleep($update_interval)
- print "$(id) Signal Mean:", self.$(id).signal_mean()
- print "$(id) Noise Variance:", self.$(id).noise_variance()
- print "$(id) SNR:", self.$(id).snr()
-_$(id)_thread = threading.Thread(target=_$(id)_run)
-_$(id)_thread.setDaemon(True)
-_$(id)_thread.start()</make>
+ <import>from grc_gnuradio import blks2 as grc_blks2</import>
+ <make>grc_blks2.probe_mpsk_snr_c(
+ type="$type",
+ alpha=$alpha,
+ probe_rate=$probe_rate,
+)</make>
<callback>set_alpha($alpha)</callback>
+ <callback>set_probe_rate($probe_rate)</callback>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <type>enum</type>
+ <option>
+ <name>SNR</name>
+ <key>snr</key>
+ </option>
+ <option>
+ <name>Signal Mean</name>
+ <key>signal_mean</key>
+ </option>
+ <option>
+ <name>Noise Variance</name>
+ <key>noise_variance</key>
+ </option>
+ </param>
<param>
<name>Alpha</name>
<key>alpha</key>
+ <value>1</value>
<type>real</type>
</param>
<param>
- <name>Update Interval (s)</name>
- <key>update_interval</key>
- <value>1.0</value>
+ <name>Probe Rate</name>
+ <key>probe_rate</key>
+ <value>10</value>
<type>real</type>
</param>
<sink>
<name>in</name>
<type>complex</type>
</sink>
+ <source>
+ <name>out</name>
+ <type>float</type>
+ </source>
</block>
diff --git a/grc/data/platforms/python/blocks/gr_probe_signal_f.xml b/grc/data/platforms/python/blocks/gr_probe_signal_f.xml
deleted file mode 100644
index 688887f47..000000000
--- a/grc/data/platforms/python/blocks/gr_probe_signal_f.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Probe Signal
-###################################################
- -->
-<block>
- <name>Probe Signal</name>
- <key>gr_probe_signal_f</key>
- <import>from gnuradio import gr</import>
- <import>import threading</import>
- <import>import time</import>
- <make>gr.probe_signal_f()
-def _$(id)_run():
- while True:
- time.sleep($update_interval)
- print "$(id) Level:", self.$(id).level()
-_$(id)_thread = threading.Thread(target=_$(id)_run)
-_$(id)_thread.setDaemon(True)
-_$(id)_thread.start()</make>
- <param>
- <name>Update Interval (s)</name>
- <key>update_interval</key>
- <value>1.0</value>
- <type>real</type>
- </param>
- <sink>
- <name>in</name>
- <type>float</type>
- </sink>
-</block>
diff --git a/grc/data/platforms/python/blocks/wxgui_numbersink2.xml b/grc/data/platforms/python/blocks/wxgui_numbersink2.xml
index e54da3e61..c3a8c52bd 100644
--- a/grc/data/platforms/python/blocks/wxgui_numbersink2.xml
+++ b/grc/data/platforms/python/blocks/wxgui_numbersink2.xml
@@ -102,7 +102,7 @@ self.GridAdd(self.$(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], $grid_pos
<param>
<name>Reference Level</name>
<key>ref_level</key>
- <value>50</value>
+ <value>0</value>
<type>real</type>
</param>
<param>
diff --git a/grc/src/grc_gnuradio/blks2/Makefile.am b/grc/src/grc_gnuradio/blks2/Makefile.am
index e3a0b8a38..528697bd9 100644
--- a/grc/src/grc_gnuradio/blks2/Makefile.am
+++ b/grc/src/grc_gnuradio/blks2/Makefile.am
@@ -27,5 +27,6 @@ ourpython_PYTHON = \
__init__.py \
error_rate.py \
packet.py \
+ probe.py \
queue.py \
selector.py
diff --git a/grc/src/grc_gnuradio/blks2/__init__.py b/grc/src/grc_gnuradio/blks2/__init__.py
index a26228f88..a66988d47 100644
--- a/grc/src/grc_gnuradio/blks2/__init__.py
+++ b/grc/src/grc_gnuradio/blks2/__init__.py
@@ -25,3 +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
diff --git a/grc/src/grc_gnuradio/blks2/probe.py b/grc/src/grc_gnuradio/blks2/probe.py
new file mode 100644
index 000000000..28721422d
--- /dev/null
+++ b/grc/src/grc_gnuradio/blks2/probe.py
@@ -0,0 +1,107 @@
+#
+# Copyright 2008 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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 3, or (at your option)
+# any later version.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr
+import threading
+import numpy
+import time
+
+class _probe_base(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.
+ """
+
+ 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),
+ )
+ self._probe_callback = probe_callback
+ self.set_probe_rate(probe_rate)
+ #create message source
+ 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)
+ self.setDaemon(True)
+ self.start()
+
+ def run(self):
+ """
+ Infinite polling loop.
+ """
+ while True:
+ time.sleep(1.0/self._probe_rate)
+ arr = numpy.array(self._probe_callback(), numpy.float32)
+ msg = gr.message_from_string(arr.tostring(), 0, gr.sizeof_float, 1)
+ self._msgq.insert_tail(msg)
+
+ def set_probe_rate(self, probe_rate):
+ self._probe_rate = probe_rate
+
+#######################################################################################
+## Probe: Average Magnitude Squared
+#######################################################################################
+class _probe_avg_mag_sqrd_base(_probe_base):
+ def __init__(self, threshold, alpha, probe_rate):
+ #create block
+ probe_block = self._probe_block_contructor[0](threshold, alpha)
+ #forward callbacks
+ self.set_alpha = probe_block.set_alpha
+ self.set_threshold = probe_block.set_threshold
+ #init
+ _probe_base.__init__(self, probe_block, probe_block.level, probe_rate)
+
+class probe_avg_mag_sqrd_c(_probe_avg_mag_sqrd_base): _probe_block_contructor = (gr.probe_avg_mag_sqrd_c,)
+class probe_avg_mag_sqrd_f(_probe_avg_mag_sqrd_base): _probe_block_contructor = (gr.probe_avg_mag_sqrd_f,)
+
+#######################################################################################
+## Probe: Density
+#######################################################################################
+class probe_density_b(_probe_base):
+ def __init__(self, alpha, probe_rate):
+ #create block
+ probe_block = gr.probe_density_b(alpha)
+ #forward callbacks
+ self.set_alpha = probe_block.set_alpha
+ #init
+ _probe_base.__init__(self, probe_block, probe_block.density, probe_rate)
+
+#######################################################################################
+## Probe: MPSK SNR
+#######################################################################################
+class probe_mpsk_snr_c(_probe_base):
+ def __init__(self, type, alpha, probe_rate):
+ """
+ Type can be "snr", "signal_mean", or "noise_variance"
+ """
+ #create block
+ probe_block = gr.probe_mpsk_snr_c(alpha)
+ #forward callbacks
+ self.set_alpha = probe_block.set_alpha
+ #init
+ _probe_base.__init__(self, probe_block, getattr(probe_block, type), probe_rate)
diff --git a/grc/src/grc_gnuradio/blks2/queue.py b/grc/src/grc_gnuradio/blks2/queue.py
index 25ea1c616..1bb9fe743 100644
--- a/grc/src/grc_gnuradio/blks2/queue.py
+++ b/grc/src/grc_gnuradio/blks2/queue.py
@@ -140,7 +140,7 @@ class _queue_source_base(gr.hier_block2):
gr.io_signature(0, 0, 0), # Input signature
gr.io_signature(1, 1, self._item_size*self._vlen) # Output signature
)
- #create message sink
+ #create message source
message_source = gr.message_source(self._item_size*self._vlen, 1)
self._msgq = message_source.msgq()
#connect
diff --git a/grc/src/grc_gnuradio/blks2/selector.py b/grc/src/grc_gnuradio/blks2/selector.py
index 0997a5ce7..2a3c64193 100644
--- a/grc/src/grc_gnuradio/blks2/selector.py
+++ b/grc/src/grc_gnuradio/blks2/selector.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
#
# Copyright 2008 Free Software Foundation, Inc.
#
diff --git a/grc/todo.txt b/grc/todo.txt
index 71a383143..d9025b668 100644
--- a/grc/todo.txt
+++ b/grc/todo.txt
@@ -6,7 +6,6 @@
-controlled step block
-throttle with sink only (source is nulled)
-simplify simple usrp
--probe blocks needs better polling mechanism
##################################################
# Features
@@ -20,7 +19,7 @@
-zoom in/out (cairo vector graphics) (use scroll wheel as control)
-search for blocks
-click and drag on whitespace to scroll
--expand preferences, allow for custome prefs, prefs dialog should infer structure
+-expand preferences, allow for custom prefs, prefs dialog should infer structure
##################################################
# Problems
@@ -29,7 +28,9 @@
-auto clean hier library
-add hier blocks to tree without restart?
-dont hide vlen controller when vlen > 1
--dont generate py files in cwd, add preference for user to choose
+-dont generate py files in .grc file dir
+-save/restore cwd
+-check for .grc file readonly, ro message in window, no save option
##################################################
# External