[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9741 - in gnuradio/trunk/grc: . data/platforms/python
From: |
jblum |
Subject: |
[Commit-gnuradio] r9741 - in gnuradio/trunk/grc: . data/platforms/python data/platforms/python/blocks src/grc_gnuradio/blks2 |
Date: |
Tue, 7 Oct 2008 21:48:34 -0600 (MDT) |
Author: jblum
Date: 2008-10-07 21:48:33 -0600 (Tue, 07 Oct 2008)
New Revision: 9741
Added:
gnuradio/trunk/grc/src/grc_gnuradio/blks2/probe.py
Removed:
gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_signal_f.xml
Modified:
gnuradio/trunk/grc/data/platforms/python/block_tree.xml
gnuradio/trunk/grc/data/platforms/python/blocks/Makefile.am
gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_avg_mag_sqrd_x.xml
gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_density_b.xml
gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml
gnuradio/trunk/grc/data/platforms/python/blocks/wxgui_numbersink2.xml
gnuradio/trunk/grc/src/grc_gnuradio/blks2/Makefile.am
gnuradio/trunk/grc/src/grc_gnuradio/blks2/__init__.py
gnuradio/trunk/grc/src/grc_gnuradio/blks2/queue.py
gnuradio/trunk/grc/src/grc_gnuradio/blks2/selector.py
gnuradio/trunk/grc/todo.txt
Log:
probe hier wrappers
Modified: gnuradio/trunk/grc/data/platforms/python/block_tree.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/block_tree.xml 2008-10-08
00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/data/platforms/python/block_tree.xml 2008-10-08
03:48:33 UTC (rev 9741)
@@ -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>
Modified: gnuradio/trunk/grc/data/platforms/python/blocks/Makefile.am
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/Makefile.am 2008-10-08
00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/Makefile.am 2008-10-08
03:48:33 UTC (rev 9741)
@@ -141,7 +141,6 @@
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 \
Modified:
gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_avg_mag_sqrd_x.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_avg_mag_sqrd_x.xml
2008-10-08 00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_avg_mag_sqrd_x.xml
2008-10-08 03:48:33 UTC (rev 9741)
@@ -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 @@
<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>
Modified: gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_density_b.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_density_b.xml
2008-10-08 00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_density_b.xml
2008-10-08 03:48:33 UTC (rev 9741)
@@ -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>
Modified:
gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml
2008-10-08 00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_mpsk_snr_c.xml
2008-10-08 03:48:33 UTC (rev 9741)
@@ -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>
Deleted: gnuradio/trunk/grc/data/platforms/python/blocks/gr_probe_signal_f.xml
Modified: gnuradio/trunk/grc/data/platforms/python/blocks/wxgui_numbersink2.xml
===================================================================
--- gnuradio/trunk/grc/data/platforms/python/blocks/wxgui_numbersink2.xml
2008-10-08 00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/data/platforms/python/blocks/wxgui_numbersink2.xml
2008-10-08 03:48:33 UTC (rev 9741)
@@ -102,7 +102,7 @@
<param>
<name>Reference Level</name>
<key>ref_level</key>
- <value>50</value>
+ <value>0</value>
<type>real</type>
</param>
<param>
Modified: gnuradio/trunk/grc/src/grc_gnuradio/blks2/Makefile.am
===================================================================
--- gnuradio/trunk/grc/src/grc_gnuradio/blks2/Makefile.am 2008-10-08
00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/src/grc_gnuradio/blks2/Makefile.am 2008-10-08
03:48:33 UTC (rev 9741)
@@ -27,5 +27,6 @@
__init__.py \
error_rate.py \
packet.py \
+ probe.py \
queue.py \
selector.py
Modified: gnuradio/trunk/grc/src/grc_gnuradio/blks2/__init__.py
===================================================================
--- gnuradio/trunk/grc/src/grc_gnuradio/blks2/__init__.py 2008-10-08
00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/src/grc_gnuradio/blks2/__init__.py 2008-10-08
03:48:33 UTC (rev 9741)
@@ -25,3 +25,4 @@
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
Added: gnuradio/trunk/grc/src/grc_gnuradio/blks2/probe.py
===================================================================
--- gnuradio/trunk/grc/src/grc_gnuradio/blks2/probe.py
(rev 0)
+++ gnuradio/trunk/grc/src/grc_gnuradio/blks2/probe.py 2008-10-08 03:48:33 UTC
(rev 9741)
@@ -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)
Modified: gnuradio/trunk/grc/src/grc_gnuradio/blks2/queue.py
===================================================================
--- gnuradio/trunk/grc/src/grc_gnuradio/blks2/queue.py 2008-10-08 00:16:00 UTC
(rev 9740)
+++ gnuradio/trunk/grc/src/grc_gnuradio/blks2/queue.py 2008-10-08 03:48:33 UTC
(rev 9741)
@@ -140,7 +140,7 @@
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
Modified: gnuradio/trunk/grc/src/grc_gnuradio/blks2/selector.py
===================================================================
--- gnuradio/trunk/grc/src/grc_gnuradio/blks2/selector.py 2008-10-08
00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/src/grc_gnuradio/blks2/selector.py 2008-10-08
03:48:33 UTC (rev 9741)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
#
# Copyright 2008 Free Software Foundation, Inc.
#
Modified: gnuradio/trunk/grc/todo.txt
===================================================================
--- gnuradio/trunk/grc/todo.txt 2008-10-08 00:16:00 UTC (rev 9740)
+++ gnuradio/trunk/grc/todo.txt 2008-10-08 03:48:33 UTC (rev 9741)
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9741 - in gnuradio/trunk/grc: . data/platforms/python data/platforms/python/blocks src/grc_gnuradio/blks2,
jblum <=