[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9173 - gnuradio/branches/features/experimental-gui
From: |
jblum |
Subject: |
[Commit-gnuradio] r9173 - gnuradio/branches/features/experimental-gui |
Date: |
Mon, 4 Aug 2008 22:45:13 -0600 (MDT) |
Author: jblum
Date: 2008-08-04 22:45:12 -0600 (Mon, 04 Aug 2008)
New Revision: 9173
Added:
gnuradio/branches/features/experimental-gui/grc_numbersink_test.py
Modified:
gnuradio/branches/features/experimental-gui/const_window.py
gnuradio/branches/features/experimental-gui/number_window.py
gnuradio/branches/features/experimental-gui/numbersink.py
Log:
numbersink work
Modified: gnuradio/branches/features/experimental-gui/const_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/const_window.py 2008-08-04
23:08:32 UTC (rev 9172)
+++ gnuradio/branches/features/experimental-gui/const_window.py 2008-08-05
04:45:12 UTC (rev 9173)
@@ -35,7 +35,7 @@
SLIDER_STEPS = 200
ALPHA_MIN_EXP, ALPHA_MAX_EXP = -6, -0.301
GAIN_MU_MIN_EXP, GAIN_MU_MAX_EXP = -6, -0.301
-DEFAULT_FRAME_RATE = 30
+DEFAULT_FRAME_RATE = 5
DEFAULT_WIN_SIZE = (500, 400)
DEFAULT_CONST_SIZE = 2048
CONST_PLOT_COLOR_SPEC = (0, 0, 1)
Added: gnuradio/branches/features/experimental-gui/grc_numbersink_test.py
===================================================================
--- gnuradio/branches/features/experimental-gui/grc_numbersink_test.py
(rev 0)
+++ gnuradio/branches/features/experimental-gui/grc_numbersink_test.py
2008-08-05 04:45:12 UTC (rev 9173)
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+##################################################
+# Gnuradio Python Flow Graph
+# Title: untitled
+# Author: unknown
+# Description: gnuradio flow graph
+# Generated: Mon Aug 4 19:40:19 2008
+##################################################
+
+from gnuradio import gr
+import numbersink
+from grc_gnuradio import wxgui as grc_wxgui
+import wx
+
+class grc_numbersink_test(grc_wxgui.top_block_gui):
+
+ def __init__(self):
+ grc_wxgui.top_block_gui.__init__(
+ self,
+ title="GRC - Executing: untitled",
+
icon="/usr/lib/python2.5/site-packages/grc/data/grc-icon-32.png",
+ )
+
+
+ ##################################################
+ # Variables
+ ##################################################
+ samp_rate = 32000
+ self.samp_rate = samp_rate
+ ampl = 50
+ _ampl_control = grc_wxgui.slider_horizontal_control(
+ window=self.GetWin(),
+ callback=self.set_ampl,
+ label="Amplitude",
+ value=ampl,
+ min=0,
+ max=100,
+ num_steps=100,
+ )
+ self.Add(_ampl_control)
+ self.ampl = ampl
+
+ ##################################################
+ # Blocks
+ ##################################################
+ self.gr_sig_source_x = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0,
ampl, 0)
+ self.gr_throttle = gr.throttle(gr.sizeof_float*1, samp_rate)
+ self.wxgui_numbersink2 = numbersink.number_sink_f(
+ self.GetWin(),
+ minval=0,
+ maxval=100,
+ decimal_places=10,
+ sample_rate=samp_rate,
+ title="Number Plot",
+ )
+ self.Add(self.wxgui_numbersink2.win)
+
+ ##################################################
+ # Connections
+ ##################################################
+ self.connect((self.gr_throttle, 0), (self.wxgui_numbersink2, 0))
+ self.connect((self.gr_sig_source_x, 0), (self.gr_throttle, 0))
+
+ def set_samp_rate(self, samp_rate):
+ self.samp_rate = samp_rate
+
+ def set_ampl(self, ampl):
+ self.ampl = ampl
+ self.gr_sig_source_x.set_amplitude(self.ampl)
+
+if __name__ == '__main__':
+ tb = grc_numbersink_test()
+ tb.Run()
+
Property changes on:
gnuradio/branches/features/experimental-gui/grc_numbersink_test.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: gnuradio/branches/features/experimental-gui/number_window.py
===================================================================
--- gnuradio/branches/features/experimental-gui/number_window.py
2008-08-04 23:08:32 UTC (rev 9172)
+++ gnuradio/branches/features/experimental-gui/number_window.py
2008-08-05 04:45:12 UTC (rev 9173)
@@ -0,0 +1,81 @@
+#
+# 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.
+#
+
+##################################################
+# Imports
+##################################################
+import common
+import numpy
+import wx
+import pubsub
+
+##################################################
+# Constants
+##################################################
+DEFAULT_NUMBER_RATE = 2
+DEFAULT_WIN_SIZE = (300, 300)
+DEFAULT_GAUGE_RANGE = 1000
+
+##################################################
+# Numbersink window with label and gauges
+##################################################
+class number_window(wx.Panel, pubsub.pubsub, common.prop_setter):
+ def __init__(
+ self,
+ parent,
+ controller,
+ size,
+ title,
+ show_gauge,
+ minval,
+ maxval,
+ decimal_places,
+ msg_key,
+ ):
+ pubsub.pubsub.__init__(self)
+ wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)
+ #setup
+ self.minval = minval
+ self.maxval = maxval
+ self.decimal_places = decimal_places
+ #gui setup
+ self.ext_controller = controller
+ sizer = wx.BoxSizer(wx.VERTICAL)
+ sizer.Add(common.LabelText(self, title), 1, wx.ALIGN_CENTER)
+ self.text = wx.StaticText(self)
+ sizer.Add(self.text, 1, wx.EXPAND)
+ self.gauge = wx.Gauge(self, range=DEFAULT_GAUGE_RANGE,
style=wx.GA_HORIZONTAL)
+ if show_gauge: self.gauge.Show()
+ else: self.gauge.Hide()
+ sizer.Add(self.gauge, 1, wx.EXPAND)
+ self.SetSizerAndFit(sizer)
+ #register events
+ self.ext_controller.subscribe(msg_key, self.handle_msg)
+
+ def handle_msg(self, msg):
+ sample = numpy.fromstring(msg, numpy.float32)[0]
+ format = "%%.%df"%self.decimal_places
+ self.text.SetLabel(format%sample)
+ #set gauge value
+ gauge_val =
DEFAULT_GAUGE_RANGE*(sample-self.minval)/(self.maxval-self.minval)
+ gauge_val = max(0, gauge_val) #clip
+ gauge_val = min(DEFAULT_GAUGE_RANGE, gauge_val) #clip
+ self.gauge.SetValue(gauge_val)
Modified: gnuradio/branches/features/experimental-gui/numbersink.py
===================================================================
--- gnuradio/branches/features/experimental-gui/numbersink.py 2008-08-04
23:08:32 UTC (rev 9172)
+++ gnuradio/branches/features/experimental-gui/numbersink.py 2008-08-05
04:45:12 UTC (rev 9173)
@@ -0,0 +1,94 @@
+#
+# 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.
+#
+
+##################################################
+# Imports
+##################################################
+import number_window
+import common
+from gnuradio import gr, blks2
+from pubsub import pubsub
+
+##################################################
+# Constants
+##################################################
+SAMPLE_RATE_KEY = 'sample_rate'
+MSG_KEY = 'msg'
+
+##################################################
+# Number sink block (wrapper for old wxgui)
+##################################################
+class number_sink_f(gr.hier_block2, common.prop_setter):
+ """!
+ An decimator block with a number window display
+ """
+
+ def __init__(
+ self,
+ parent,
+ minval=0,
+ maxval=1,
+ decimal_places=10,
+ show_gauge=True,
+ sample_rate=1,
+ number_rate=number_window.DEFAULT_NUMBER_RATE,
+ title='',
+ size=number_window.DEFAULT_WIN_SIZE,
+ ):
+ gr.hier_block2.__init__(
+ self,
+ "number_sink",
+ gr.io_signature(1, 1, gr.sizeof_float),
+ gr.io_signature(0, 0, 0),
+ )
+ #blocks
+ msgq = gr.msg_queue(2)
+ sd = blks2.stream_to_vector_decimator(
+ item_size=gr.sizeof_float,
+ sample_rate=sample_rate,
+ vec_rate=number_rate,
+ vec_len=1,
+ )
+ sink = gr.message_sink(gr.sizeof_float, msgq, True)
+ #connect
+ self.connect(self, sd, sink)
+ #controller
+ self.controller = pubsub()
+ self.controller.subscribe(SAMPLE_RATE_KEY, sd.set_sample_rate)
+ #start input watcher
+ def set_msg(msg): self.controller[MSG_KEY] = msg
+ common.input_watcher(msgq, set_msg)
+ #create window
+ self.win = number_window.number_window(
+ parent=parent,
+ controller=self.controller,
+ size=size,
+ title=title,
+ minval=minval,
+ maxval=maxval,
+ decimal_places=decimal_places,
+ show_gauge=show_gauge,
+ msg_key=MSG_KEY,
+ )
+ #register callbacks from window for external use
+ for attr in filter(lambda a: a.startswith('set_'),
dir(self.win)):
+ setattr(self, attr, getattr(self.win, attr))
+ self._register_set_prop(self.controller, SAMPLE_RATE_KEY)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9173 - gnuradio/branches/features/experimental-gui,
jblum <=