On 11/02/2011 08:03 PM, Johnathan Corgan wrote:
On Wed, Nov 2, 2011 at 16:43, Marcus D. Leech <mle...@ripnet.com <mailto:mle...@ripnet.com>> wrote:


To be clear, the problem appears to be with the block itself. GRC correctly adds the "set_delay" callback spooge.

    But calling that callback in the C++ code doesn't appear to affect
    the delay.


Changing the delay via the callback changes the history requirements of the block, which will not take effect until the thread executing the work() function returns, and could be hundreds or thousands of items in the future. But it does take effect eventually.

One way to change this behavior would be to implement the pattern used in the FIR blocks for when the number of taps changes. Changing the delay would set a flag that the work function could check for and return immediately. However, this wold come a high price, as the work() function currently uses memcpy to move data from the input to the output, and instead you'd have to have an iterative loop with a conditional equality check in the middle.

Johnathan
Your assertion that "it does take effect eventually" appears to not be true in reality (at least in this little test graph) (attached).

Looking at the code, there's an inline function, set_delay, that calls set_history(). And the SWIG goop appears to be correct.


--
Marcus Leech
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org

Attachment: delay_test.grc
Description: application/gnuradio-grc

#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: Delay Test
# Generated: Wed Nov  2 20:17:46 2011
##################################################

from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.eng_option import eng_option
from gnuradio.gr import firdes
from gnuradio.wxgui import forms
from gnuradio.wxgui import scopesink2
from grc_gnuradio import wxgui as grc_wxgui
from optparse import OptionParser
import wx

class delay_test(grc_wxgui.top_block_gui):

	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Delay Test")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 200e3
		self.delay = delay = 0

		##################################################
		# Blocks
		##################################################
		_delay_sizer = wx.BoxSizer(wx.VERTICAL)
		self._delay_text_box = forms.text_box(
			parent=self.GetWin(),
			sizer=_delay_sizer,
			value=self.delay,
			callback=self.set_delay,
			label="Delay",
			converter=forms.float_converter(),
			proportion=0,
		)
		self._delay_slider = forms.slider(
			parent=self.GetWin(),
			sizer=_delay_sizer,
			value=self.delay,
			callback=self.set_delay,
			minimum=0,
			maximum=10,
			num_steps=10,
			style=wx.SL_HORIZONTAL,
			cast=float,
			proportion=1,
		)
		self.Add(_delay_sizer)
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=2,
			trig_mode=gr.gr_TRIG_MODE_AUTO,
			y_axis_label="Counts",
		)
		self.Add(self.wxgui_scopesink2_0.win)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_float*1, samp_rate)
		self.gr_sig_source_x_0 = gr.sig_source_f(samp_rate, gr.GR_COS_WAVE, 25000, 1, 0)
		self.gr_delay_0 = gr.delay(gr.sizeof_float*1, int(delay))

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_delay_0, 0), (self.wxgui_scopesink2_0, 0))
		self.connect((self.gr_sig_source_x_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_delay_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.wxgui_scopesink2_0, 1))

	def get_samp_rate(self):
		return self.samp_rate

	def set_samp_rate(self, samp_rate):
		self.samp_rate = samp_rate
		self.wxgui_scopesink2_0.set_sample_rate(self.samp_rate)
		self.gr_sig_source_x_0.set_sampling_freq(self.samp_rate)

	def get_delay(self):
		return self.delay

	def set_delay(self, delay):
		self.delay = delay
		self.gr_delay_0.set_delay(int(self.delay))
		self._delay_slider.set_value(self.delay)
		self._delay_text_box.set_value(self.delay)

if __name__ == '__main__':
	parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
	(options, args) = parser.parse_args()
	tb = delay_test()
	tb.Run(True)

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to