Пример #1
0
 def test_001_square_ff (self):
     src_data = (-3, 4, -5.5, 2, 3)
     expected_result = (9, 16, 30.25, 4, 9)
     src = gr.vector_source_f (src_data)
     sqr = howto.square_ff ()
     dst = gr.vector_sink_f ()
     self.tb.connect (src, sqr)
     self.tb.connect (sqr, dst)
     self.tb.run ()
     result_data = dst.data ()
     self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6)
Пример #2
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Howto Square")

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 10e3

		##################################################
		# Blocks
		##################################################
		self.sink = scopesink2.scope_sink_f(
			self.GetWin(),
			title="Input",
			sample_rate=samp_rate,
			v_scale=20,
			v_offset=0,
			t_scale=0.002,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
		)
		self.Add(self.sink.win)
		self.sink2 = scopesink2.scope_sink_f(
			self.GetWin(),
			title="Output",
			sample_rate=samp_rate,
			v_scale=0,
			v_offset=0,
			t_scale=0.002,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
		)
		self.Add(self.sink2.win)
		self.sqr = howto.square_ff()
		self.src = gr.vector_source_f(([float(n)-50 for n in range(100)]), True, 1)
		self.thr = gr.throttle(gr.sizeof_float*1, samp_rate)

		##################################################
		# Connections
		##################################################
		self.connect((self.thr, 0), (self.sqr, 0))
		self.connect((self.src, 0), (self.thr, 0))
		self.connect((self.thr, 0), (self.sink, 0))
		self.connect((self.sqr, 0), (self.sink2, 0))