commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9248 - gnuradio/branches/developers/jblum/glwxgui/gr-


From: jblum
Subject: [Commit-gnuradio] r9248 - gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python
Date: Mon, 11 Aug 2008 18:49:14 -0600 (MDT)

Author: jblum
Date: 2008-08-11 18:49:13 -0600 (Mon, 11 Aug 2008)
New Revision: 9248

Added:
   
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/const_window.py
   
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/constsink_gl.py
Modified:
   gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/Makefile.am
Log:
imported constsink

Modified: 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/Makefile.am
===================================================================
--- gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/Makefile.am  
2008-08-12 00:44:25 UTC (rev 9247)
+++ gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/Makefile.am  
2008-08-12 00:49:13 UTC (rev 9248)
@@ -34,6 +34,8 @@
        __init__.py                     \
        common.py                       \
        constants.py                    \
+       constsink_gl.py                 \
+       const_window.py                 \
        form.py                         \
        fftsink2.py                     \
        fftsink_gl.py                   \

Copied: 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/const_window.py 
(from rev 9247, gnuradio/branches/features/experimental-gui/const_window.py)
===================================================================
--- 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/const_window.py  
                            (rev 0)
+++ 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/const_window.py  
    2008-08-12 00:49:13 UTC (rev 9248)
@@ -0,0 +1,189 @@
+#
+# 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 plotter
+import common
+import wx
+import numpy
+import math
+import pubsub
+from constants import *
+
+##################################################
+# Constants
+##################################################
+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 = 5
+DEFAULT_WIN_SIZE = (500, 400)
+DEFAULT_CONST_SIZE = 2048
+CONST_PLOT_COLOR_SPEC = (0, 0, 1)
+MARKER_TYPES = (
+       ('Dot Small', 1.0),
+       ('Dot Medium', 2.0),
+       ('Dot Large', 3.0),
+       ('Line Link', None),
+)
+DEFAULT_MARKER_TYPE = MARKER_TYPES[1][1]
+
+##################################################
+# Constellation window control panel
+##################################################
+class control_panel(wx.Panel):
+       """!
+       A control panel with wx widgits to control the plotter.
+       """
+       def __init__(self, parent):
+               """!
+               Create a new control panel.
+               @param parent the wx parent window
+               """
+               self.parent = parent
+               wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)
+               control_box = wx.BoxSizer(wx.VERTICAL)
+               self.marker_index = 2
+               #begin control box
+               control_box.AddStretchSpacer()
+               control_box.Add(common.LabelText(self, 'Options'), 0, 
wx.ALIGN_CENTER)
+               #marker
+               control_box.AddStretchSpacer()
+               self.marker_chooser = common.DropDownController(self, 'Marker', 
MARKER_TYPES, parent, MARKER_KEY)
+               control_box.Add(self.marker_chooser, 0, wx.EXPAND)
+               #alpha
+               control_box.AddStretchSpacer()
+               self.alpha_slider = common.LogSliderController(
+                       self, 'Alpha',
+                       ALPHA_MIN_EXP, ALPHA_MAX_EXP, SLIDER_STEPS,
+                       parent.ext_controller, parent.alpha_key,
+               )
+               control_box.Add(self.alpha_slider, 0, wx.EXPAND)
+               #gain_mu
+               control_box.AddStretchSpacer()
+               self.gain_mu_slider = common.LogSliderController(
+                       self, 'Gain Mu',
+                       GAIN_MU_MIN_EXP, GAIN_MU_MAX_EXP, SLIDER_STEPS,
+                       parent.ext_controller, parent.gain_mu_key,
+               )
+               control_box.Add(self.gain_mu_slider, 0, wx.EXPAND)
+               #run/stop
+               control_box.AddStretchSpacer()
+               self.run_button = common.RunStopButtonController(self, parent, 
RUNNING_KEY)
+               control_box.Add(self.run_button, 0, wx.EXPAND)
+               #set sizer
+               self.SetSizerAndFit(control_box)
+
+##################################################
+# Constellation window with plotter and control panel
+##################################################
+class const_window(wx.Panel, pubsub.pubsub, common.prop_setter):
+       def __init__(
+               self,
+               parent,
+               controller,
+               size,
+               title,
+               msg_key,
+               alpha_key,
+               beta_key,
+               gain_mu_key,
+               gain_omega_key,
+       ):
+               pubsub.pubsub.__init__(self)
+               #setup
+               self.ext_controller = controller
+               self.alpha_key = alpha_key
+               self.beta_key = beta_key
+               self.gain_mu_key = gain_mu_key
+               self.gain_omega_key = gain_omega_key
+               #init panel and plot
+               wx.Panel.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
+               self.plotter = plotter.channel_plotter(self)
+               self.plotter.SetSize(wx.Size(*size))
+               self.plotter.set_title(title)
+               self.plotter.set_x_label('Inphase')
+               self.plotter.set_y_label('Quadrature')
+               self.plotter.enable_point_label(True)
+               #setup the box with plot and controls
+               self.control_panel = control_panel(self)
+               main_box = wx.BoxSizer(wx.HORIZONTAL)
+               main_box.Add(self.plotter, 1, wx.EXPAND)
+               main_box.Add(self.control_panel, 0, wx.EXPAND)
+               self.SetSizerAndFit(main_box)
+               #alpha and gain mu 2nd orders
+               def set_beta(alpha): self.ext_controller[self.beta_key] = 
.25*alpha**2
+               self.ext_controller.subscribe(self.alpha_key, set_beta)
+               def set_gain_omega(gain_mu): 
self.ext_controller[self.gain_omega_key] = .25*gain_mu**2
+               self.ext_controller.subscribe(self.gain_mu_key, set_gain_omega)
+               #initial setup
+               self.ext_controller[self.alpha_key] = 
self.ext_controller[self.alpha_key]
+               self.ext_controller[self.gain_mu_key] = 
self.ext_controller[self.gain_mu_key]
+               self._register_set_prop(self, RUNNING_KEY, True)
+               self._register_set_prop(self, X_DIVS_KEY, 8)
+               self._register_set_prop(self, Y_DIVS_KEY, 8)
+               self._register_set_prop(self, MARKER_KEY, DEFAULT_MARKER_TYPE)
+               #register events
+               self.ext_controller.subscribe(msg_key, self.handle_msg)
+               for key in (
+                       X_DIVS_KEY, Y_DIVS_KEY,
+               ): self.subscribe(key, self.update_grid)
+               #initial update
+               self.update_grid()
+
+       def handle_msg(self, msg):
+               """!
+               Plot the samples onto the complex grid.
+               @param msg the array of complex samples
+               """
+               if not self[RUNNING_KEY]: return
+               #convert to complex floating point numbers
+               samples = numpy.fromstring(msg, numpy.complex64)
+               real = numpy.real(samples)
+               imag = numpy.imag(samples)
+               #plot
+               self.plotter.set_waveform(
+                       channel=0,
+                       samples=(real, imag),
+                       color_spec=CONST_PLOT_COLOR_SPEC,
+                       marker=self[MARKER_KEY],
+               )
+               #update the plotter
+               self.plotter.update()
+
+       def update_grid(self):
+               #grid parameters
+               x_divs = self[X_DIVS_KEY]
+               y_divs = self[Y_DIVS_KEY]
+               #update the x axis
+               x_max = 2.0
+               self.plotter.set_x_grid(-x_max, x_max, 
common.get_clean_num(2.0*x_max/x_divs))
+               #update the y axis
+               y_max = 2.0
+               self.plotter.set_y_grid(-y_max, y_max, 
common.get_clean_num(2.0*y_max/y_divs))
+               #update plotter
+               self.plotter.update()
+
+
+
+

Copied: 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/constsink_gl.py 
(from rev 9247, gnuradio/branches/features/experimental-gui/constsink.py)
===================================================================
--- 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/constsink_gl.py  
                            (rev 0)
+++ 
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/constsink_gl.py  
    2008-08-12 00:49:13 UTC (rev 9248)
@@ -0,0 +1,142 @@
+#
+# 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 const_window
+import common
+from gnuradio import gr, blks2
+from pubsub import pubsub
+from constants import *
+
+##################################################
+# Constellation sink block (wrapper for old wxgui)
+##################################################
+class const_sink_c(gr.hier_block2, common.prop_setter):
+       """!
+       A constellation block with a gui window.
+       """
+
+       def __init__(
+               self,
+               parent,
+               title='',
+               sample_rate=1,
+               size=const_window.DEFAULT_WIN_SIZE,
+               frame_rate=const_window.DEFAULT_FRAME_RATE,
+               const_size=const_window.DEFAULT_CONST_SIZE,
+               #mpsk recv params
+               M=4,
+               theta=0,
+               alpha=0.005,
+               fmax=0.06,
+               mu=0.5,
+               gain_mu=0.005,
+               symbol_rate=1,
+               omega_limit=0.005,
+       ):
+               #init
+               gr.hier_block2.__init__(
+                       self,
+                       "const_sink",
+                       gr.io_signature(1, 1, gr.sizeof_gr_complex),
+                       gr.io_signature(0, 0, 0),
+               )
+               #blocks
+               sd = blks2.stream_to_vector_decimator(
+                       item_size=gr.sizeof_gr_complex,
+                       sample_rate=sample_rate,
+                       vec_rate=frame_rate,
+                       vec_len=const_size,
+               )
+               beta = .25*alpha**2 #redundant, will be updated
+               fmin = -fmax
+               gain_omega = .25*gain_mu**2 #redundant, will be updated
+               omega = 1 #set_sample_rate will update this
+               # Costas frequency/phase recovery loop
+               # Critically damped 2nd order PLL
+               self._costas = gr.costas_loop_cc(alpha, beta, fmax, fmin, M)
+               # Timing recovery loop
+               # Critically damped 2nd order DLL
+               self._retime = gr.clock_recovery_mm_cc(omega, gain_omega, mu, 
gain_mu, omega_limit)
+               #sync = gr.mpsk_receiver_cc(
+               #       M, #psk order
+               #       theta,
+               #       alpha,
+               #       beta,
+               #       fmin,
+               #       fmax,
+               #       mu,
+               #       gain_mu,
+               #       omega,
+               #       gain_omega,
+               #       omega_limit,
+               #)
+               agc = gr.feedforward_agc_cc(16, 1)
+               msgq = gr.msg_queue(2)
+               sink = gr.message_sink(gr.sizeof_gr_complex*const_size, msgq, 
True)
+               #connect
+               self.connect(self, self._costas, self._retime, agc, sd, sink)
+               #controller
+               def setter(p, k, x): # lambdas can't have assignments :(
+                   p[k] = x
+               self.controller = pubsub()
+               self.controller.subscribe(ALPHA_KEY, self._costas.set_alpha)
+               self.controller.publish(ALPHA_KEY, self._costas.alpha)
+               self.controller.subscribe(BETA_KEY, self._costas.set_beta)
+               self.controller.publish(BETA_KEY, self._costas.beta)
+               self.controller.subscribe(GAIN_MU_KEY, self._retime.set_gain_mu)
+               self.controller.publish(GAIN_MU_KEY, self._retime.gain_mu)
+               self.controller.subscribe(OMEGA_KEY, self._retime.set_omega)
+               self.controller.publish(OMEGA_KEY, self._retime.omega)
+               self.controller.subscribe(GAIN_OMEGA_KEY, 
self._retime.set_gain_omega)
+               self.controller.publish(GAIN_OMEGA_KEY, self._retime.gain_omega)
+               self.controller.subscribe(SAMPLE_RATE_KEY, sd.set_sample_rate)
+               self.controller.subscribe(SAMPLE_RATE_KEY, lambda x: 
setter(self.controller, OMEGA_KEY, float(x)/symbol_rate))
+               self.controller.publish(SAMPLE_RATE_KEY, sd.sample_rate)
+               #initial update
+               self.controller[SAMPLE_RATE_KEY] = sample_rate
+               #start input watcher
+               common.input_watcher(msgq, lambda x: setter(self.controller, 
MSG_KEY, x))
+               #create window
+               self.win = const_window.const_window(
+                       parent=parent,
+                       controller=self.controller,
+                       size=size,
+                       title=title,
+                       msg_key=MSG_KEY,
+                       alpha_key=ALPHA_KEY,
+                       beta_key=BETA_KEY,
+                       gain_mu_key=GAIN_MU_KEY,
+                       gain_omega_key=GAIN_OMEGA_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, ALPHA_KEY)
+               self._register_set_prop(self.controller, BETA_KEY)
+               self._register_set_prop(self.controller, GAIN_MU_KEY)
+               self._register_set_prop(self.controller, OMEGA_KEY)
+               self._register_set_prop(self.controller, GAIN_OMEGA_KEY)
+               self._register_set_prop(self.controller, SAMPLE_RATE_KEY)
+
+





reply via email to

[Prev in Thread] Current Thread [Next in Thread]