Beispiel #1
0
 def test_007_connect_invalid_dst_port_neg(self):
     hblock = gr.hier_block2(
         "test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)
     )
     nop1 = gr.nop(gr.sizeof_int)
     nop2 = gr.nop(gr.sizeof_int)
     self.assertRaises(ValueError, lambda: hblock.connect(nop1, (nop2, -1)))
 def test_007_connect_invalid_dst_port_neg(self):
     hblock = gr.hier_block2("test_block",
                             gr.io_signature(1, 1, gr.sizeof_int),
                             gr.io_signature(1, 1, gr.sizeof_int))
     nop1 = gr.nop(gr.sizeof_int)
     nop2 = gr.nop(gr.sizeof_int)
     self.assertRaises(ValueError, lambda: hblock.connect(nop1, (nop2, -1)))
Beispiel #3
0
	def __init__(self):
		gr.top_block.__init__(self)
		
		usage = "%prog: [options] samples_file"
		parser = OptionParser(option_class=eng_option, usage=usage)
		(options, args) = parser.parse_args ()
		if len(args)<1:
			# print "using gaussian noise as source"
			# self.sigsrc = gr.noise_source_c(gr.GR_GAUSSIAN,10e6)
			print "using repeating random vector as source"
			self.sigsrc = gr.vector_source_c([10e6*(random.random() + 1j*random.random()) for i in range(0,100000)],True)
			self.src = gr.throttle( gr.sizeof_gr_complex,2048000)
			self.connect(self.sigsrc, self.src)
		else:
			filename = args[0]
			print "using samples from file " + filename
			self.src = gr.file_source(gr.sizeof_gr_complex, filename, False)

		dp = parameters.dab_parameters(1)
		rp = parameters.receiver_parameters(1)
		self.sync_dab = ofdm_sync_dab(dp, rp, False)
		self.nop0 = gr.nop(gr.sizeof_gr_complex)
		self.nop1 = gr.nop(gr.sizeof_char)
		self.connect(self.src, self.sync_dab, self.nop0)
		self.connect((self.sync_dab,1), self.nop1)
 def test_005_connect_output_in_use(self):
     hblock = gr.hier_block2("test_block",
                             gr.io_signature(1, 1, gr.sizeof_int),
                             gr.io_signature(1, 1, gr.sizeof_int))
     nop1 = gr.nop(gr.sizeof_int)
     nop2 = gr.nop(gr.sizeof_int)
     hblock.connect(nop1, hblock)
     self.assertRaises(ValueError, lambda: hblock.connect(nop2, hblock))
 def test_013_disconnect_input_not_connected(self):
     hblock = gr.hier_block2("test_block",
                             gr.io_signature(1, 1, gr.sizeof_int),
                             gr.io_signature(1, 1, gr.sizeof_int))
     nop1 = gr.nop(gr.sizeof_int)
     nop2 = gr.nop(gr.sizeof_int)
     hblock.connect(hblock, nop1)
     self.assertRaises(ValueError, lambda: hblock.disconnect(hblock, nop2))
Beispiel #6
0
 def test_005_connect_output_in_use(self):
     hblock = gr.hier_block2(
         "test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)
     )
     nop1 = gr.nop(gr.sizeof_int)
     nop2 = gr.nop(gr.sizeof_int)
     hblock.connect(nop1, hblock)
     self.assertRaises(ValueError, lambda: hblock.connect(nop2, hblock))
Beispiel #7
0
 def test_013_disconnect_input_not_connected(self):
     hblock = gr.hier_block2(
         "test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)
     )
     nop1 = gr.nop(gr.sizeof_int)
     nop2 = gr.nop(gr.sizeof_int)
     hblock.connect(hblock, nop1)
     self.assertRaises(ValueError, lambda: hblock.disconnect(hblock, nop2))
 def test_113 (self):
     fg = self.fg
     nop1 = gr.nop (gr.sizeof_int)
     nop2 = gr.nop (gr.sizeof_int)
     nop3 = gr.nop (gr.sizeof_int)
     fg.connect ((nop1, 0), (nop2, 0))
     fg.connect ((nop1, 0), (nop3, 0))
     fg._setup_connections ()
     self.assertEqual (1, nop1.detail().noutputs())
Beispiel #9
0
	def __init__(self):
		gr.top_block.__init__(self)
		

		usage = "%prog: [options] samples_file"
		parser = OptionParser(option_class=eng_option, usage=usage)
  		parser.add_option("-m", "--dab-mode", type="int", default=1,
        	     	help="DAB mode [default=%default]")
		parser.add_option("-F", "--filter-input", action="store_true", default=False,
                          help="Enable FFT filter at input")
  		parser.add_option("-s", "--resample-fixed", type="float", default=1,
			help="resample by a fixed factor (fractional interpolation)")
		parser.add_option("-S", "--autocorrect-sample-rate", action="store_true", default=False,
                          help="Estimate sample rate offset and resample (dynamic fractional interpolation)")
  		parser.add_option('-r', '--sample-rate', type="int", default=2048000,
	     		help="Use non-standard sample rate (default=%default)")
  		parser.add_option('-e', '--equalize-magnitude', action="store_true", default=False,
	     		help="Enable individual carrier magnitude equalizer")
  		parser.add_option('-d', '--debug', action="store_true", default=False,
	     		help="Write output to files")
  		parser.add_option('-v', '--verbose', action="store_true", default=False,
	     		help="Print status messages")
		(options, args) = parser.parse_args ()
	
		dp = parameters.dab_parameters(options.dab_mode, verbose=options.verbose, sample_rate=options.sample_rate)

		rp = parameters.receiver_parameters(options.dab_mode, input_fft_filter=options.filter_input, autocorrect_sample_rate=options.autocorrect_sample_rate, sample_rate_correction_factor=options.resample_fixed, equalize_magnitude=options.equalize_magnitude, verbose=options.verbose)

		if len(args)<1:
			if options.verbose: print "-> using repeating random vector as source"
			self.sigsrc = gr.vector_source_c([10e6*(random.random() + 1j*random.random()) for i in range(0,100000)],True)
			self.ns_simulate = gr.vector_source_c([0.01]*dp.ns_length+[1]*dp.symbols_per_frame*dp.symbol_length,1)
			self.mult = gr.multiply_cc() # simulate null symbols ...
			self.src = gr.throttle( gr.sizeof_gr_complex,2048000)
			self.connect(self.sigsrc, (self.mult, 0))
			self.connect(self.ns_simulate, (self.mult, 1))
			self.connect(self.mult, self.src)
		else:
			filename = args[0]
			if options.verbose: print "-> using samples from file " + filename
			self.src = gr.file_source(gr.sizeof_gr_complex, filename, False)

		self.dab_demod = ofdm.ofdm_demod(dp, rp, debug=options.debug, verbose=options.verbose)
		
		self.connect(self.src, self.dab_demod)

		# sink output to nowhere 
		self.nop0 = gr.nop(gr.sizeof_char*dp.num_carriers/4)
		self.nop1 = gr.nop(gr.sizeof_char)
		self.connect((self.dab_demod,0),self.nop0)
		self.connect((self.dab_demod,1),self.nop1)
Beispiel #10
0
 def test_019_disconnect_output_exceeds(self):
     hblock = gr.hier_block2(
         "test_block", gr.io_signature(1, 1, gr.sizeof_int), gr.io_signature(1, 1, gr.sizeof_int)
     )
     nop1 = gr.nop(gr.sizeof_int)
     hblock.connect(nop1, hblock)
     self.assertRaises(ValueError, lambda: hblock.disconnect(nop1, (hblock, 1)))
Beispiel #11
0
 def test_012_disconnect_input(self):
     hblock = gr.hier_block2("test_block",
                             gr.io_signature(1, 1, gr.sizeof_int),
                             gr.io_signature(1, 1, gr.sizeof_int))
     nop1 = gr.nop(gr.sizeof_int)
     hblock.connect(hblock, nop1)
     hblock.disconnect(hblock, nop1)
Beispiel #12
0
 def test_005_connect_invalid_src_port_exceeds(self):
     hblock = gr.hier_block2("test_block",
                             gr.io_signature(1, 1, gr.sizeof_int),
                             gr.io_signature(1, 1, gr.sizeof_int))
     nop1 = gr.nop(gr.sizeof_int)
     self.assertRaises(ValueError, lambda: hblock.connect(
         (hblock, 1), nop1))
Beispiel #13
0
 def test_016_disconnect_output(self):
     hblock = gr.hier_block2("test_block",
                             gr.io_signature(1, 1, gr.sizeof_int),
                             gr.io_signature(1, 1, gr.sizeof_int))
     nop1 = gr.nop(gr.sizeof_int)
     hblock.connect(nop1, hblock)
     hblock.disconnect(nop1, hblock)
 def test_104_trivial_dag_check (self):
     fg = self.fg
     nop1 = gr.nop (gr.sizeof_int)
     fg.connect (nop1, nop1)
     fg.validate ()
     self.assertRaises (gr.NotDAG,
                        lambda : fg.topological_sort (fg.all_blocks ()))
    def test_005_connect_invalid_src_port_exceeds(self):
	hblock = gr.hier_block2("test_block", 
				gr.io_signature(1,1,gr.sizeof_int), 
				gr.io_signature(1,1,gr.sizeof_int))
	nop1 = gr.nop(gr.sizeof_int)
	self.assertRaises(ValueError, 
	    lambda: hblock.connect((hblock, 1), nop1))
 def test_107 (self):
     fg = self.fg
     src1 = gr.null_source (gr.sizeof_int)
     src2 = gr.null_source (gr.sizeof_int)
     nop1 = gr.nop (gr.sizeof_int)
     nop2 = gr.nop (gr.sizeof_int)
     dst1 = gr.null_sink (gr.sizeof_int)
     dst2 = gr.null_sink (gr.sizeof_int)
     
     fg.connect (src1, nop1)
     fg.connect (nop1, dst1)
     fg.connect (src2, nop2)
     fg.connect (nop2, dst2)
     fg.validate ()
     ts = fg.topological_sort (fg.all_blocks ())
     self.assertEqual ([src2, nop2, dst2, src1, nop1, dst1], ts)
    def test_012_disconnect_input(self):
	hblock = gr.hier_block2("test_block", 
				gr.io_signature(1,1,gr.sizeof_int), 
				gr.io_signature(1,1,gr.sizeof_int))
	nop1 = gr.nop(gr.sizeof_int)
	hblock.connect(hblock, nop1)
        hblock.disconnect(hblock, nop1)
    def test_016_disconnect_output(self):
	hblock = gr.hier_block2("test_block", 
				gr.io_signature(1,1,gr.sizeof_int), 
				gr.io_signature(1,1,gr.sizeof_int))
	nop1 = gr.nop(gr.sizeof_int)
	hblock.connect(nop1, hblock)
        hblock.disconnect(nop1, hblock)
 def test_014_connect_varargs (self):
     fg = self.fg
     src1 = gr.null_source (gr.sizeof_int)
     nop1 = gr.nop (gr.sizeof_int)
     dst1 = gr.null_sink (gr.sizeof_int)
     fg.connect (src1, nop1, dst1)
     fg.validate ()
 def body_201 (self):
     fg = self.fg
     src1 = gr.null_source (gr.sizeof_int)
     src2 = gr.null_source (gr.sizeof_int)
     nop1 = gr.nop (gr.sizeof_int)
     nop2 = gr.nop (gr.sizeof_int)
     dst1 = gr.null_sink (gr.sizeof_int)
     dst2 = gr.null_sink (gr.sizeof_int)
     
     fg.connect (nop2, dst2)
     fg.connect (src1, nop1)
     fg.connect (src2, nop2)
     fg.connect (nop1, dst1)
     fg.validate ()
     p = fg.partition_graph (fg.all_blocks ())
     self.assertEqual ([[src2, nop2, dst2], [src1, nop1, dst1]], p)
     self.assertEqual ((6,0,0,0), all_counts ())
Beispiel #21
0
 def test_019_disconnect_output_exceeds(self):
     hblock = gr.hier_block2("test_block",
                             gr.io_signature(1, 1, gr.sizeof_int),
                             gr.io_signature(1, 1, gr.sizeof_int))
     nop1 = gr.nop(gr.sizeof_int)
     hblock.connect(nop1, hblock)
     self.assertRaises(ValueError,
                       lambda: hblock.disconnect(nop1, (hblock, 1)))
 def test_103_tsort_three_b (self):
     fg = self.fg
     src1 = gr.null_source (gr.sizeof_int)
     nop1 = gr.nop (gr.sizeof_int)
     dst1 = gr.null_sink (gr.sizeof_int)
     fg.connect (nop1, dst1)
     fg.connect (src1, nop1)
     fg.validate ()
     self.assertEqual ([src1, nop1, dst1], fg.topological_sort (fg.all_blocks ()))
 def test_013_connect_varargs (self):
     fg = self.fg
     src1 = gr.null_source (gr.sizeof_int)
     nop1 = gr.nop (gr.sizeof_int)
     dst1 = gr.null_sink (gr.sizeof_int)
     self.assertRaises (ValueError,
                        lambda : fg.connect ())
     self.assertRaises (ValueError,
                        lambda : fg.connect (src1))
 def test_008_validate (self):
     fg = self.fg
     src1 = gr.null_source (gr.sizeof_int)
     nop1 = gr.nop (gr.sizeof_int)
     dst1 = gr.null_sink (gr.sizeof_int)
     dst2 = gr.null_sink (gr.sizeof_int)
     fg.connect ((src1, 0), (nop1, 0))
     fg.connect ((src1, 0), (nop1, 1))
     fg.connect ((nop1, 0), (dst1, 0))
     fg.connect ((nop1, 1), (dst2, 0))
     fg.validate ()
 def test_010_validate (self):
     fg = self.fg
     src1 = gr.null_source (gr.sizeof_int)
     nop1 = gr.nop (gr.sizeof_int)
     dst1 = gr.null_sink (gr.sizeof_int)
     dst2 = gr.null_sink (gr.sizeof_int)
     fg.connect ((src1, 0), (nop1, 0))
     fg.connect ((src1, 0), (nop1, 1))
     fg.connect ((nop1, 0), (dst1, 0))
     fg.connect ((nop1, 2), (dst2, 0))
     self.assertRaises (ValueError,
                        lambda : fg.validate ())