3 # Copyright 2004,2007 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 from gnuradio import gr, gr_unittest
26 class test_sig_source (gr_unittest.TestCase):
29 self.tb = gr.top_block()
34 def test_pll_refout (self):
35 expected_result = (1.1489677586e-07,
137 freq = sampling_freq / 100
140 beta = alpha * alpha / 4.0
144 src = gr.sig_source_c (sampling_freq, gr.GR_COS_WAVE, freq, 1.0)
145 pll = gr.pll_freqdet_cf(alpha, beta, maxf, minf)
146 head = gr.head (gr.sizeof_float, int (freq))
147 dst = gr.vector_sink_f ()
149 self.tb.connect (src, pll, head)
150 self.tb.connect (head, dst)
153 dst_data = dst.data ()
155 # convert it from normalized frequency to absolute frequency (Hz)
156 dst_data = [i*(sampling_freq/(2*math.pi)) for i in dst_data]
158 self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 3)
160 if __name__ == '__main__':