diff options
author | jcorgan | 2009-07-10 01:26:37 +0000 |
---|---|---|
committer | jcorgan | 2009-07-10 01:26:37 +0000 |
commit | a9154607d6f6fd2bfbafd732dccf9edef35e1e6e (patch) | |
tree | 39d76114da110de5269a340cab2c651410d7637d /gr-wxgui/src/python/fftsink_nongl.py | |
parent | e921d54419e95c097cdecf21a2de7c393eb75f18 (diff) | |
download | gnuradio-a9154607d6f6fd2bfbafd732dccf9edef35e1e6e.tar.gz gnuradio-a9154607d6f6fd2bfbafd732dccf9edef35e1e6e.tar.bz2 gnuradio-a9154607d6f6fd2bfbafd732dccf9edef35e1e6e.zip |
Refactor msgq thread classes to use gru.msgq_runner
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11407 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-wxgui/src/python/fftsink_nongl.py')
-rw-r--r-- | gr-wxgui/src/python/fftsink_nongl.py | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/gr-wxgui/src/python/fftsink_nongl.py b/gr-wxgui/src/python/fftsink_nongl.py index a1033e818..ca5e91fdb 100644 --- a/gr-wxgui/src/python/fftsink_nongl.py +++ b/gr-wxgui/src/python/fftsink_nongl.py @@ -25,7 +25,6 @@ from gnuradio.wxgui import stdgui2 import wx import plot import numpy -import threading import math DIV_LEVELS = (1, 2, 5, 10, 20) @@ -193,34 +192,28 @@ class DataEvent(wx.PyEvent): self.__class__ (self.GetId()) -class input_watcher (threading.Thread): +class input_watcher (gru.msgq_runner): def __init__ (self, msgq, fft_size, event_receiver, **kwds): - threading.Thread.__init__ (self, **kwds) - self.setDaemon (1) - self.msgq = msgq self.fft_size = fft_size self.event_receiver = event_receiver - self.keep_running = True - self.start () - - def run (self): - while (self.keep_running): - msg = self.msgq.delete_head() # blocking read of message queue - itemsize = int(msg.arg1()) - nitems = int(msg.arg2()) - - s = msg.to_string() # get the body of the msg as a string - - # There may be more than one FFT frame in the message. - # If so, we take only the last one - if nitems > 1: - start = itemsize * (nitems - 1) - s = s[start:start+itemsize] - - complex_data = numpy.fromstring (s, numpy.float32) - de = DataEvent (complex_data) - wx.PostEvent (self.event_receiver, de) - del de + gru.msgq_runner.__init__(self, msgq, self.handle_msg) + + def handle_msg(self, msg): + itemsize = int(msg.arg1()) + nitems = int(msg.arg2()) + + s = msg.to_string() # get the body of the msg as a string + + # There may be more than one FFT frame in the message. + # If so, we take only the last one + if nitems > 1: + start = itemsize * (nitems - 1) + s = s[start:start+itemsize] + + complex_data = numpy.fromstring (s, numpy.float32) + de = DataEvent (complex_data) + wx.PostEvent (self.event_receiver, de) + del de class control_panel(wx.Panel): |