def test_003_real_uniform_pool(self): src = analog.fastnoise_source_f(type=analog.GR_UNIFORM, **self.default_args) src2 = analog.fastnoise_source_f(type=analog.GR_UNIFORM, **self.default_args) self.assertTrue( numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples())))
def test_003_real_laplacian_pool(self): src = analog.fastnoise_source_f(type=analog.GR_LAPLACIAN, **self.default_args) src2 = analog.fastnoise_source_f(type=analog.GR_LAPLACIAN, **self.default_args) self.assertTrue( numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples())))
def test_noise_source_real(): top = gr.top_block() src = analog.fastnoise_source_f(analog.GR_UNIFORM, math.sqrt(2)) probe = blocks.probe_rate(gr.sizeof_float) top.connect(src, probe) return top, probe
def test_binary_slicer_fb(): top = gr.top_block() src = analog.fastnoise_source_f(analog.GR_UNIFORM, math.sqrt(2)) slicer = digital.binary_slicer_fb() probe = blocks.probe_rate(gr.sizeof_char) top.connect(src, slicer, probe) return top, probe
def __init__(self, ebno_db=0, min_errors=100, samp_per_sym=1): gr.top_block.__init__(self, "BER 4FSK ") ################################################## # Parameters ################################################## self.ebno_db = ebno_db self.min_errors = min_errors self.samp_per_sym = samp_per_sym ################################################## # Variables ################################################## self.symb_rate = symb_rate = 4800 self.bits_per_sym = bits_per_sym = 1 self.bit_rate = bit_rate = float(symb_rate)*bits_per_sym self.average_power = average_power = 1.0 self.ebno = ebno = 10**(ebno_db/10.0) self.eb = eb = average_power/bit_rate self.samp_rate = samp_rate = symb_rate*samp_per_sym self.no = no = eb/ebno self.noise_variance = noise_variance = no*samp_rate/2.0 ################################################## # Blocks ################################################## self.sample_counter = sample_counter() self.probe_avg_power = analog.probe_avg_mag_sqrd_f(0, 1) self.pack_rx_bits = blocks.pack_k_bits_bb(8) self.pack_msg_bits = blocks.pack_k_bits_bb(8) self.glfsr = digital.glfsr_source_b(8, True, 0, 1) self.four_level_symbol_mapper_0 = four_level_symbol_mapper( symbol_map=[-1,1], ) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([-1,1]), 1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_per_sym) self.blocks_add_xx_0 = blocks.add_vff(1) self.ber_sink = blocks.vector_sink_f(1) self.ber_measure = fec.ber_bf(True, min_errors, -7.0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(analog.GR_GAUSSIAN, math.sqrt(noise_variance), 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.ber_measure, 0), (self.ber_sink, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.four_level_symbol_mapper_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.probe_avg_power, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.four_level_symbol_mapper_0, 0), (self.sample_counter, 0)) self.connect((self.glfsr, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.glfsr, 0), (self.pack_msg_bits, 0)) self.connect((self.pack_msg_bits, 0), (self.ber_measure, 0)) self.connect((self.pack_rx_bits, 0), (self.ber_measure, 1)) self.connect((self.sample_counter, 0), (self.pack_rx_bits, 0))
def test_002(self): # Test get methods set_type = analog.GR_GAUSSIAN set_ampl = 10 op = analog.fastnoise_source_f(set_type, set_ampl, 10) get_type = op.type() get_ampl = op.amplitude() self.assertEqual(get_type, set_type) self.assertEqual(get_ampl, set_ampl)
def run_test_real(self, form): """ Run test case with float input/output """ tb = gr.top_block() src = analog.fastnoise_source_f(type=form, **self.default_args) head = blocks.head(nitems=self.num_items, sizeof_stream_item=gr.sizeof_float) sink = blocks.vector_sink_f() tb.connect(src, head, sink) tb.run() return numpy.array(sink.data())
def run_fastnoise_source_f(self): ntype = analog.GR_GAUSSIAN ampl = 10 seed = 0 self.blocks = [] self.tb = gr.top_block() self.blocks.append(analog.fastnoise_source_f(ntype, ampl, seed)) self.blocks.append(blocks.head(gr.sizeof_float, self.N)) self.blocks.append(blocks.null_sink(gr.sizeof_float)) self.tb.connect(*self.blocks) self.tb.run()
def __init__(self, esno, seed=0): gr.hier_block2.__init__( self, "Gaussian Noise Adder", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) self.esno = esno self.seed = seed self.sigma = 10.0**(-esno/10.0) self.sigma = numpy.sqrt(self.sigma/2.0) self.noise_source = analog.fastnoise_source_f(analog.GR_GAUSSIAN, self.sigma, self.seed) self.adder = blocks.add_ff() self.connect((self, 0), (self.adder, 0)) self.connect(self.noise_source, (self.adder, 1)) self.connect((self.adder, 0), (self,0))
def test_001(self): # Just confirm that we can instantiate a noise source op = analog.fastnoise_source_f(analog.GR_GAUSSIAN, 10, 10)
def __init__(self): gr.top_block.__init__(self, "HFS first channel") ################################################## # Variables ################################################## self.snr = snr = 1 self.vol = vol = 1 self.tau_a = tau_a = 1 / 100. self.tau = tau = 0.002 self.snr_out_func = snr_out_func = ([0] * 3) self.samp_rate = samp_rate = 48000 self.out_rms_func = out_rms_func = 0 self.noSpread = noSpread = 1 self.kN = kN = pow(10.0, (-snr / 20.0)) self.freqShift = freqShift = 0.0 self.fd = fd = 1 self.en_noise = en_noise = 0 self.doppler_ir = doppler_ir = [ 0.0016502763167573274, 0.0018854799389366934, 0.002149957633383614, 0.0024466994528029662, 0.002778907461425479, 0.003149998028185868, 0.003563602180973301, 0.00402356375450247, 0.004533935060796761, 0.0050989698117900155, 0.005723113028669535, 0.006410987682800636, 0.007167377828853199, 0.007997208012493867, 0.008905518763040982, 0.00989743801603955, 0.010978148351927763, 0.012152849984840378, 0.013426719489994542, 0.014804864318746317, 0.016292273216847054, 0.01789376273305468, 0.019613920081278834, 0.021457042698902442, 0.023427074925696508, 0.025527542310538734, 0.027761484135525694, 0.030131384827462734, 0.03263910500345486, 0.035285812968654906, 0.03807191754835305, 0.04099700319171279, 0.04405976832879332, 0.04725796799434838, 0.050588361749672524, 0.05404666793605477, 0.057627525278984175, 0.06132446283016882, 0.06512987918400244, 0.0690350318359975, 0.073030037462906, 0.07710388379815894, 0.08124445365265866, 0.08543856149104095, 0.08967200281887802, 0.0939296164688993, 0.09819535969651079, 0.10245239580938088, 0.10668319386560887, 0.1108696397832219, 0.11499315801386097, 0.11903484274903825, 0.12297559745183839, 0.12679628134392928, 0.1304778613306593, 0.13400156771907581, 0.1373490519778611, 0.14050254470705797, 0.14344501193124823, 0.14616030780428022, 0.14863332181791858, 0.15085011864154488, 0.1527980687853246, 0.154465968374505, 0.15584414644656272, 0.15692455833401583, 0.15770086387153975, 0.1581684893637365, 0.15832467246620405, 0.1581684893637365, 0.15770086387153975, 0.15692455833401583, 0.15584414644656272, 0.154465968374505, 0.1527980687853246, 0.15085011864154488, 0.14863332181791858, 0.14616030780428022, 0.14344501193124823, 0.14050254470705797, 0.1373490519778611, 0.13400156771907581, 0.1304778613306593, 0.12679628134392928, 0.12297559745183839, 0.11903484274903825, 0.11499315801386097, 0.1108696397832219, 0.10668319386560887, 0.10245239580938088, 0.09819535969651079, 0.0939296164688993, 0.08967200281887802, 0.08543856149104095, 0.08124445365265866, 0.07710388379815894, 0.073030037462906, 0.0690350318359975, 0.06512987918400244, 0.06132446283016882, 0.057627525278984175, 0.05404666793605477, 0.050588361749672524, 0.04725796799434838, 0.04405976832879332, 0.04099700319171279, 0.03807191754835305, 0.035285812968654906, 0.03263910500345486, 0.030131384827462734, 0.027761484135525694, 0.025527542310538734, 0.023427074925696508, 0.021457042698902442, 0.019613920081278834, 0.01789376273305468, 0.016292273216847054, 0.014804864318746317, 0.013426719489994542, 0.012152849984840378, 0.010978148351927763, 0.00989743801603955, 0.008905518763040982, 0.007997208012493867, 0.007167377828853199, 0.006410987682800636, 0.005723113028669535, 0.0050989698117900155, 0.004533935060796761, 0.00402356375450247, 0.003563602180973301, 0.003149998028185868, 0.002778907461425479, 0.0024466994528029662, 0.002149957633383614, 0.0018854799389366934, 0.0016502763167573274 ] self.ampl = ampl = [[1.0, 0.0], [1.0, 0.0]] ################################################## # Blocks ################################################## self.snr_out = blocks.probe_signal_f() self.out_rms = blocks.probe_signal_f() def _snr_out_func_probe(): while True: val = self.snr_out.level() try: self.set_snr_out_func(val) except AttributeError: pass time.sleep(1.0 / (10)) _snr_out_func_thread = threading.Thread(target=_snr_out_func_probe) _snr_out_func_thread.daemon = True _snr_out_func_thread.start() self.single_pole_iir_filter_xx_0_0 = filter.single_pole_iir_filter_ff( 2 * pi * tau_a / samp_rate, 1) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( 2 * pi * tau_a / samp_rate, 1) def _out_rms_func_probe(): while True: val = self.out_rms.level() try: self.set_out_rms_func(val) except AttributeError: pass time.sleep(1.0 / (10)) _out_rms_func_thread = threading.Thread(target=_out_rms_func_probe) _out_rms_func_thread.daemon = True _out_rms_func_thread.start() self.low_pass_filter_2 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1_0 = filter.interp_fir_filter_ccf( int(samp_rate / 100), firdes.low_pass(ampl[0][1] * (samp_rate / 100.0), samp_rate, 50, 25, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_ccf( int(samp_rate / 100), firdes.low_pass(ampl[0][0] * (samp_rate / 100.0), samp_rate, 50, 25, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1750 + 100, 600, firdes.WIN_HAMMING, 6.76)) self.epy_block_0_0 = epy_block_0_0.blk(fd=fd) self.epy_block_0 = epy_block_0.blk(fd=fd) self.blocks_selector_0_0 = blocks.selector(gr.sizeof_gr_complex * 1, noSpread, 0) self.blocks_selector_0_0.set_enabled(True) self.blocks_selector_0 = blocks.selector(gr.sizeof_gr_complex * 1, noSpread, 0) self.blocks_selector_0.set_enabled(True) self.blocks_rms_xx_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 / samp_rate) self.blocks_rms_xx_0 = blocks.rms_cf(2 * pi * tau_a * 100 / samp_rate) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_ff(en_noise) self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_cc(vol) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc(vol) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_ff( 2 * sqrt(ampl[0][0]**2 + ampl[0][1]**2) * 2) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(0.5) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.5) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(tau * samp_rate)) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_2_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_2 = blocks.complex_to_mag_squared(1) self.blocks_add_xx_1 = blocks.add_vff(1) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.audio_source_0 = audio.source(samp_rate, 'in1', True) self.audio_sink_0_0_0 = audio.sink(samp_rate, 'out3', False) self.audio_sink_0_0 = audio.sink(samp_rate, 'out2', False) self.analog_sig_source_x_2 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freqShift, 1, 0, 0) self.analog_sig_source_x_0_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, 1e-0 * kN, 3) self.analog_fastnoise_source_x_2 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 1, 1, 8192) self.analog_fastnoise_source_x_1 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 1, 0, 8192) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f( analog.GR_GAUSSIAN, 0.3, 0, 8192) self.analog_const_source_x_2 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_const_source_x_1_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, ampl[0][1]) self.analog_const_source_x_1 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, ampl[0][0]) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_const_source_x_1, 0), (self.blocks_selector_0, 1)) self.connect((self.analog_const_source_x_1_0, 0), (self.blocks_selector_0_0, 1)) self.connect((self.analog_const_source_x_2, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_multiply_const_vxx_3, 0)) self.connect((self.analog_fastnoise_source_x_1, 0), (self.epy_block_0, 0)) self.connect((self.analog_fastnoise_source_x_2, 0), (self.epy_block_0_0, 0)) self.connect((self.analog_noise_source_x_1, 0), (self.low_pass_filter_2, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.analog_sig_source_x_2, 0), (self.blocks_multiply_xx_0_0_0_0_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_add_xx_1, 0), (self.audio_sink_0_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_2, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_2_0, 0), (self.single_pole_iir_filter_xx_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0_0_0_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_0_0_0_0, 2)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.audio_sink_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0), (self.blocks_complex_to_mag_squared_2_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_complex_to_mag_squared_2, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.snr_out, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_rms_xx_0_0, 0), (self.out_rms, 0)) self.connect((self.blocks_selector_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_selector_0_0, 0), (self.blocks_multiply_xx_0_0_0_0, 1)) self.connect((self.epy_block_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.epy_block_0_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_selector_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.blocks_selector_0_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.blocks_multiply_xx_0_0_0_0_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.single_pole_iir_filter_xx_0_0, 0), (self.blocks_divide_xx_1, 1))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.carrier_freq = carrier_freq = 25e3 ################################################## # Blocks ################################################## self._carrier_freq_layout = Qt.QVBoxLayout() self._carrier_freq_tool_bar = Qt.QToolBar(self) self._carrier_freq_layout.addWidget(self._carrier_freq_tool_bar) self._carrier_freq_tool_bar.addWidget(Qt.QLabel("Carrier Freq"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._carrier_freq_counter = qwt_counter_pyslot() self._carrier_freq_counter.setRange(0, samp_rate/2, 1) self._carrier_freq_counter.setNumButtons(2) self._carrier_freq_counter.setValue(self.carrier_freq) self._carrier_freq_tool_bar.addWidget(self._carrier_freq_counter) self._carrier_freq_counter.valueChanged.connect(self.set_carrier_freq) self._carrier_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._carrier_freq_slider.setRange(0, samp_rate/2, 1) self._carrier_freq_slider.setValue(self.carrier_freq) self._carrier_freq_slider.setMinimumWidth(200) self._carrier_freq_slider.valueChanged.connect(self.set_carrier_freq) self._carrier_freq_layout.addWidget(self._carrier_freq_slider) self.top_layout.addLayout(self._carrier_freq_layout) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=1000000, decimation=44100, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(1.0/20) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-160, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 40960, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["red", "blue", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 0.25, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_wavfile_source_0 = blocks.wavfile_source("/home/student/Desktop/SuzVega-TomsDinerRemix-44100Hz-mono.wav", True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, 44100,True) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, )) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, carrier_freq, 1, 0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(analog.GR_GAUSSIAN, 0.0005, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 1))
def test_003_real_laplacian_pool(self): src = analog.fastnoise_source_f(type=analog.GR_LAPLACIAN, **self.default_args) src2 = analog.fastnoise_source_f(type=analog.GR_LAPLACIAN, **self.default_args) self.assertTrue(numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples())))
def __init__(self): gr.top_block.__init__(self, "simple BER test") Qt.QWidget.__init__(self) self.setWindowTitle("simple BER test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "ber_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.rate = rate = 2 self.polys = polys = [79, 109] self.k = k = 7 self.framebits = framebits = 4096 self.esno = esno = 15 self.samp_rate = samp_rate = 35000000 self.puncpat = puncpat = '11' self.noise = noise = numpy.sqrt((10.0**(-esno / 10.0)) / 2.0) self.enc = enc = map( (lambda a: fec.cc_encoder_make(framebits, k, rate, (polys), 0, fec.CC_STREAMING, False) ), range(0, 1)) self.dec = dec = map((lambda a: fec.cc_decoder.make( framebits, k, rate, (polys), 0, -1, fec.CC_STREAMING, False)), range(0, 1)) self.berminerrs = berminerrs = 100 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate '', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1.25, 1.25) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -10) self.qtgui_number_sink_0.set_max(i, 10) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(True) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win) self.fec_extended_encoder_0 = fec.extended_encoder( encoder_obj_list=enc, threading='capillary', puncpat=puncpat) self.fec_extended_decoder_0 = fec.extended_decoder( decoder_obj_list=dec, threading=None, ann=None, puncpat=puncpat, integration_period=10000) self.fec_ber_bf_0 = fec.ber_bf(False, berminerrs, -7.0) self._esno_range = Range(0, 15, 0.25, 15, 200) self._esno_win = RangeWidget(self._esno_range, self.set_esno, 'EsN0', "counter_slider", float) self.top_grid_layout.addWidget(self._esno_win) self.digital_map_bb_0 = digital.map_bb(([-1, 1])) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_char_to_float_1 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 1000)), True) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f( analog.GR_GAUSSIAN, noise, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.fec_extended_decoder_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.fec_ber_bf_0, 1)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_1, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.fec_extended_decoder_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.digital_map_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.carrier_freq = carrier_freq = 25e3 ################################################## # Blocks ################################################## self._carrier_freq_layout = Qt.QVBoxLayout() self._carrier_freq_tool_bar = Qt.QToolBar(self) self._carrier_freq_layout.addWidget(self._carrier_freq_tool_bar) self._carrier_freq_tool_bar.addWidget(Qt.QLabel("Carrier Freq" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._carrier_freq_counter = qwt_counter_pyslot() self._carrier_freq_counter.setRange(0, samp_rate / 2, 1) self._carrier_freq_counter.setNumButtons(2) self._carrier_freq_counter.setValue(self.carrier_freq) self._carrier_freq_tool_bar.addWidget(self._carrier_freq_counter) self._carrier_freq_counter.valueChanged.connect(self.set_carrier_freq) self._carrier_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._carrier_freq_slider.setRange(0, samp_rate / 2, 1) self._carrier_freq_slider.setValue(self.carrier_freq) self._carrier_freq_slider.setMinimumWidth(200) self._carrier_freq_slider.valueChanged.connect(self.set_carrier_freq) self._carrier_freq_layout.addWidget(self._carrier_freq_slider) self.top_layout.addLayout(self._carrier_freq_layout) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=1000000, decimation=44100, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(1.0 / 20) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-160, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 40960, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "red", "blue", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 0.25, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_wavfile_source_0 = blocks.wavfile_source( "/home/student/Desktop/SuzVega-TomsDinerRemix-44100Hz-mono.wav", True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, 44100, True) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, )) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, carrier_freq, 1, 0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f( analog.GR_GAUSSIAN, 0.0005, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 1))
def __init__(self): gr.top_block.__init__(self, "Interleaver Demo", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("Interleaver Demo") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "interleaver_demo") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.intl_indices = intl_indices = np.random.permutation(160) ################################################## # Blocks ################################################## self.symbolmapping_interleaver_0_0 = symbolmapping.interleaver_ff(intl_indices, 1 > 0, False) self.symbolmapping_interleaver_0 = symbolmapping.interleaver_ff(intl_indices, 1 > 0, True) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 2, #number of inputs None # parent ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10'] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(analog.GR_GAUSSIAN, 1, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.symbolmapping_interleaver_0, 0)) self.connect((self.symbolmapping_interleaver_0, 0), (self.symbolmapping_interleaver_0_0, 0)) self.connect((self.symbolmapping_interleaver_0_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Pulse Amplitude Modulation") Qt.QWidget.__init__(self) self.setWindowTitle("Pulse Amplitude Modulation") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "text_pam") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 44100 self.lowF = lowF = 1200 self.highF = highF = 2200 self.baud_rate = baud_rate = 1000 self.sps = sps = int(samp_rate / baud_rate) self.fsk_deviation_hz = fsk_deviation_hz = highF - lowF self.bits_per_symbol = bits_per_symbol = 1 self.tag = tag = gr.tag_utils.python_to_tag( (0, pmt.intern("Z"), pmt.intern("0x5a"), pmt.intern("Vsrc"))) self.samp_dly_fsk = samp_dly_fsk = int(4 * sps) self.samp_dly = samp_dly = int(7.04 * sps) self.ptype = ptype = 'rect' self.polar = polar = 0 self.noise = noise = 0 self.filter_taps = filter_taps = firdes.low_pass( 1.0, samp_rate, fsk_deviation_hz, 400) self.baud_delay_fsk = baud_delay_fsk = 0 self.baud_delay = baud_delay = 0 self.alpha = alpha = 0.2 self.M = M = 2**bits_per_symbol self.An = An = 0 ################################################## # Blocks ################################################## self._samp_dly_fsk_range = Range(0, sps * 8, 1, int(4 * sps), 200) self._samp_dly_fsk_win = RangeWidget(self._samp_dly_fsk_range, self.set_samp_dly_fsk, 'samp_dly_fsk', "counter_slider", int) self.top_grid_layout.addWidget(self._samp_dly_fsk_win) self._samp_dly_range = Range(0, sps * 8, 1, int(7.04 * sps), 200) self._samp_dly_win = RangeWidget(self._samp_dly_range, self.set_samp_dly, 'samp_dly', "counter_slider", int) self.top_grid_layout.addWidget(self._samp_dly_win) # Create the options list self._ptype_options = ["rect", "rcf", "rrcf", "tri", "man", "msin"] # Create the labels list self._ptype_labels = ["rect", "rcf", "rrcf", "tri", "man", "msin"] # Create the combo box self._ptype_tool_bar = Qt.QToolBar(self) self._ptype_tool_bar.addWidget(Qt.QLabel('ptype' + ": ")) self._ptype_combo_box = Qt.QComboBox() self._ptype_tool_bar.addWidget(self._ptype_combo_box) for _label in self._ptype_labels: self._ptype_combo_box.addItem(_label) self._ptype_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ptype_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._ptype_options.index(i))) self._ptype_callback(self.ptype) self._ptype_combo_box.currentIndexChanged.connect( lambda i: self.set_ptype(self._ptype_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._ptype_tool_bar) # Create the options list self._polar_options = ( 0, 1, ) # Create the labels list self._polar_labels = ( 'unipolar', 'polar', ) # Create the combo box self._polar_tool_bar = Qt.QToolBar(self) self._polar_tool_bar.addWidget(Qt.QLabel('polar' + ": ")) self._polar_combo_box = Qt.QComboBox() self._polar_tool_bar.addWidget(self._polar_combo_box) for _label in self._polar_labels: self._polar_combo_box.addItem(_label) self._polar_callback = lambda i: Qt.QMetaObject.invokeMethod( self._polar_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._polar_options.index(i))) self._polar_callback(self.polar) self._polar_combo_box.currentIndexChanged.connect( lambda i: self.set_polar(self._polar_options[i])) # Create the radio buttons self.top_grid_layout.addWidget(self._polar_tool_bar) self._noise_range = Range(0, 1, 1e-3, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'noise level in [mV]', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_win) self._lowF_range = Range(1000, 100000, 1, 1200, 200) self._lowF_win = RangeWidget(self._lowF_range, self.set_lowF, 'lowF', "counter_slider", float) self.top_grid_layout.addWidget(self._lowF_win) self._highF_range = Range(1000, 100000, 1, 2200, 200) self._highF_win = RangeWidget(self._highF_range, self.set_highF, 'highF', "counter_slider", float) self.top_grid_layout.addWidget(self._highF_win) self._baud_delay_fsk_range = Range(0, 8, 1, 0, 8) self._baud_delay_fsk_win = RangeWidget(self._baud_delay_fsk_range, self.set_baud_delay_fsk, 'Baud delay FSK', "counter_slider", int) self.top_grid_layout.addWidget(self._baud_delay_fsk_win) self._baud_delay_range = Range(0, 8, 1, 0, 8) self._baud_delay_win = RangeWidget(self._baud_delay_range, self.set_baud_delay, 'Baud delay', "counter_slider", int) self.top_grid_layout.addWidget(self._baud_delay_win) self._alpha_range = Range(0, 1, 0.5, 0.2, 200) self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha, 'alpha', "counter_slider", float) self.top_grid_layout.addWidget(self._alpha_win) self._An_range = Range(0, 1, 0.01, 0, 200) self._An_win = RangeWidget(self._An_range, self.set_An, 'An', "counter_slider", float) self.top_grid_layout.addWidget(self._An_win) self.sym2byte_float2byteMSB_0_0 = sym2byte_float2byteMSB( baud_delay=baud_delay_fsk, bit_endianess=1, bits_per_symbol=bits_per_symbol, bits_to_use_per_byte_mask=255, gain=1, invert=0, polar=polar, ) self.sym2byte_float2byteMSB_0 = sym2byte_float2byteMSB( baud_delay=baud_delay, bit_endianess=1, bits_per_symbol=bits_per_symbol, bits_to_use_per_byte_mask=255, gain=1, invert=0, polar=polar, ) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(True) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(True) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 4 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(True) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(True) self.qtgui_time_sink_x_1.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(4): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "Z") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "Z") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(4): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_sink_x_0 = qtgui.sink_f( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0.enable_rf_freq(False) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in range(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self.pamrcvr216_ff_0 = pamrcvr216_ff( a_sps=sps, b_ptype='rect', c_alpha=alpha, d_k=sps / 2, dly=samp_dly_fsk, ) self.pamrcvr216_cc_0 = pamrcvr216_cc( a_sps=sps, b_ptype=ptype, c_alpha=alpha, d_k=sps / 2, dly=samp_dly, ) self.pam_xmtr16_ff_0 = pam_xmtr16_ff( a_sps=sps, b_ptype=ptype, c_alpha=alpha, d_k=sps / 2, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf( 1, filter_taps, (lowF + highF) / 2, samp_rate) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=0.0, epsilon=1.0, taps=[1.0 + 1.0j], noise_seed=0, block_tags=False) self.byte2sym_byte2floatMSB_0 = byte2sym_byte2floatMSB( bit_endianess=1, bits_per_symbol=bits_per_symbol, bits_to_use_per_byte_mask=255, invert=0, polar=polar, ) self.blocks_vector_source_x_0 = blocks.vector_source_b( list(ord(i) for i in 'Zombie'), True, 1, [tag]) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_not_xx_0 = blocks.not_bb() self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1, '/dev/pts/2', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, '/dev/pts/0', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0_1 = blocks.add_const_bb(2) self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(-0.5) self.blocks_add_const_vxx_0 = blocks.add_const_ff(0) self._baud_rate_range = Range(0, 8000, 1, 1000, 200) self._baud_rate_win = RangeWidget(self._baud_rate_range, self.set_baud_rate, 'Fb', "counter_slider", int) self.top_grid_layout.addWidget(self._baud_rate_win) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, lowF, 1, 0, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, highF, 2, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, highF, 1, 0, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0)) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f( analog.GR_GAUSSIAN, An, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_add_const_vxx_0_1, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0_0, 2)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_1_0, 2)) self.connect((self.blocks_add_xx_0_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_1, 2)) self.connect((self.blocks_char_to_float_0_0, 0), (self.pamrcvr216_ff_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1, 3)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.sym2byte_float2byteMSB_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_multiply_xx_1, 0), (self.pamrcvr216_cc_0, 0)) self.connect((self.blocks_not_xx_0, 0), (self.blocks_add_const_vxx_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.byte2sym_byte2floatMSB_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.byte2sym_byte2floatMSB_0, 0), (self.pam_xmtr16_ff_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_not_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.pam_xmtr16_ff_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.pam_xmtr16_ff_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.pam_xmtr16_ff_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.pamrcvr216_cc_0, 1), (self.blocks_complex_to_float_0, 0)) self.connect((self.pamrcvr216_cc_0, 1), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.pamrcvr216_cc_0, 2), (self.qtgui_time_sink_x_0, 1)) self.connect((self.pamrcvr216_cc_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.pamrcvr216_ff_0, 2), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.pamrcvr216_ff_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.pamrcvr216_ff_0, 1), (self.sym2byte_float2byteMSB_0_0, 0)) self.connect((self.sym2byte_float2byteMSB_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.sym2byte_float2byteMSB_0, 0), (self.fec_ber_bf_0, 1)) self.connect((self.sym2byte_float2byteMSB_0_0, 0), (self.blocks_file_sink_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "TEXT TXRX") Qt.QWidget.__init__(self) self.setWindowTitle("TEXT TXRX") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "text_simulation") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.tail_len = tail_len = 5 self.sps = sps = 10 self.ptype = ptype = 'rect' self.bps = bps = 1 self.alpha = alpha = 0.2 self.tag = tag = gr.tag_utils.python_to_tag( (0, pmt.intern("Z"), pmt.intern("0x5a"), pmt.intern("Vsrc"))) self.samp_rate = samp_rate = 320e3 self.pttaps2 = pttaps2 = pam.pamhRt(sps, ptype, [tail_len, alpha]) self.pttaps = pttaps = pam.pamampt(sps, ptype, [tail_len, alpha]) self.polarity = polarity = 1 self.noise = noise = 0 self.gain = gain = 1 self.delay = delay = 0 self.b_eds = b_eds = 0 self.M = M = 2**bps self.FB = FB = 32000 ################################################## # Blocks ################################################## # Create the options list self._polarity_options = ( 0, 1, ) # Create the labels list self._polarity_labels = ( 'unipolar', 'polar', ) # Create the combo box # Create the radio buttons self._polarity_group_box = Qt.QGroupBox('polarity' + ": ") self._polarity_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._polarity_button_group = variable_chooser_button_group() self._polarity_group_box.setLayout(self._polarity_box) for i, _label in enumerate(self._polarity_labels): radio_button = Qt.QRadioButton(_label) self._polarity_box.addWidget(radio_button) self._polarity_button_group.addButton(radio_button, i) self._polarity_callback = lambda i: Qt.QMetaObject.invokeMethod( self._polarity_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._polarity_options.index(i))) self._polarity_callback(self.polarity) self._polarity_button_group.buttonClicked[int].connect( lambda i: self.set_polarity(self._polarity_options[i])) self.top_grid_layout.addWidget(self._polarity_group_box) self._noise_range = Range(0, 2, 0.01, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'noise', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "RX_TD", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "TX_TD", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0_0_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "RX_FD", #name 1) self.qtgui_freq_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0_0.enable_control_panel(False) self.qtgui_freq_sink_x_0_0_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "TX_FD", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) # Create the options list self._ptype_options = ( 'rect', 'tri', 'sinc', 'rcf', 'rrcf', ) # Create the labels list self._ptype_labels = ( 'rect', 'tri', 'sinc', 'rcf', 'rrcf', ) # Create the combo box # Create the radio buttons self._ptype_group_box = Qt.QGroupBox('ptype' + ": ") self._ptype_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._ptype_button_group = variable_chooser_button_group() self._ptype_group_box.setLayout(self._ptype_box) for i, _label in enumerate(self._ptype_labels): radio_button = Qt.QRadioButton(_label) self._ptype_box.addWidget(radio_button) self._ptype_button_group.addButton(radio_button, i) self._ptype_callback = lambda i: Qt.QMetaObject.invokeMethod( self._ptype_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._ptype_options.index(i))) self._ptype_callback(self.ptype) self._ptype_button_group.buttonClicked[int].connect( lambda i: self.set_ptype(self._ptype_options[i])) self.top_grid_layout.addWidget(self._ptype_group_box) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff( sps, pttaps) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.fir_filter_xxx_1 = filter.fir_filter_fff(sps, [1]) self.fir_filter_xxx_1.declare_sample_delay(0) self.fir_filter_xxx_0_0 = filter.fir_filter_fff(1, pttaps2) self.fir_filter_xxx_0_0.declare_sample_delay(0) self.blocks_vector_source_x_0 = blocks.vector_source_b( list(ord(i) for i in "Zombie"), True, 1, [tag]) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( bps, b_eds) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( bps, b_eds) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(gain) self.blocks_float_to_char_0 = blocks.float_to_char( 1, polarity * 0.5 + (1 - polarity) * 1) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1, '/dev/pts/0', False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, '/dev/pts/1', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_0_1 = blocks.delay(gr.sizeof_char * 1, delay) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1, delay) self.blocks_char_to_float_0 = blocks.char_to_float( 1, polarity * 0.5 + (1 - polarity) * 1) self.blocks_and_const_xx_0_0 = blocks.and_const_bb(255) self.blocks_and_const_xx_0 = blocks.and_const_bb(255) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(polarity * (M - 1) + (1 - polarity) * 0) self.blocks_add_const_vxx_0 = blocks.add_const_ff(-polarity * (M - 1) + (1 - polarity) * 0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f( analog.GR_GAUSSIAN, noise, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.fir_filter_xxx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_and_const_xx_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_and_const_xx_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_and_const_xx_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.blocks_delay_0_1, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_delay_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_and_const_xx_0_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_and_const_xx_0, 0)) self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.qtgui_freq_sink_x_0_0_0_0, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 0))
def test_003_real_uniform_pool(self): src = analog.fastnoise_source_f(type=analog.GR_UNIFORM, **self.default_args) src2 = analog.fastnoise_source_f(type=analog.GR_UNIFORM, **self.default_args) self.assertTrue(numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples())))
def __init__(self): gr.top_block.__init__(self, "Minimal Working Example") Qt.QWidget.__init__(self) self.setWindowTitle("Minimal Working Example") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "minimal_working_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-3, 3) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blanker_blanker_ff_0 = blanker.blanker_ff(20, 20, 20, 20) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f( analog.GR_GAUSSIAN, 1, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blanker_blanker_ff_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blanker_blanker_ff_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Aprs Rx Test") Qt.QWidget.__init__(self) self.setWindowTitle("Aprs Rx Test") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "aprs_rx_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48e3 self.sps = sps = int(samp_rate / 1200) self.gain_mu = gain_mu = 0.175 ################################################## # Blocks ################################################## self.show_text_0 = display.show_text() self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._show_text_0_win, 2, 0, 1, 2) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2048, #size 1024, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.fsk_demod_0 = fsk_demod( baud=1200, fsk_hi_tone=2200, fsk_lo_tone=1200, in_sps=sps, out_sps=2, ) self.fft_filter_xxx_0 = filter.fft_filter_fff(1, (firdes.band_pass( 1, samp_rate, 1000, 2400, 300, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.epy_block_0 = epy_block_0.blk() self.digital_hdlc_deframer_bp_0_0 = digital.hdlc_deframer_bp(32, 500) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( 2 * (1 + 0.0), 0.25 * gain_mu * gain_mu, 0.5, gain_mu, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_wavfile_source_0 = blocks.wavfile_source( '/home/handiko/aprs_test.wav', True) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_not_xx_0 = blocks.not_bb() self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.1, )) self.blocks_and_const_xx_0 = blocks.and_const_bb(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(int(samp_rate), '', True) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f( analog.GR_UNIFORM, 0.1, 0, 8192) ################################################## # Connections ################################################## self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.epy_block_0, 'hdlc in')) self.msg_connect((self.epy_block_0, 'ax25 out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.fsk_demod_0, 0)) self.connect((self.blocks_and_const_xx_0, 0), (self.digital_hdlc_deframer_bp_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_not_xx_0, 0), (self.blocks_and_const_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.show_text_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_not_xx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fsk_demod_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Filter Taps") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.transition = transition = 1000 self.samp_rate = samp_rate = 32000 self.cutoff_low = cutoff_low = 2000 self.cutoff_high = cutoff_high = 14000 self.bp_low = bp_low = 6000 self.bp_high = bp_high = 10000 self.lp_taps = lp_taps = firdes.low_pass(1.0, samp_rate, cutoff_high, transition, firdes.WIN_HAMMING, 6.76) self.hp_taps = hp_taps = firdes.high_pass(1.0, samp_rate, cutoff_low, transition, firdes.WIN_HAMMING, 6.76) self.bp_taps = bp_taps = firdes.band_pass(1.0, samp_rate, bp_low, bp_high, transition, firdes.WIN_HAMMING, 6.76) ################################################## # Blocks ################################################## self.notebook = self.notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "lp") self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "hp") self.notebook.AddPage(grc_wxgui.Panel(self.notebook), "bp") self.Add(self.notebook) self.wxgui_fftsink2_0_0_1_0_1 = fftsink2.fft_sink_f( self.notebook.GetPage(2).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=4096, fft_rate=15, average=False, avg_alpha=None, title='filtro pasa banda', peak_hold=False, win=window.flattop, ) self.notebook.GetPage(2).Add(self.wxgui_fftsink2_0_0_1_0_1.win) self.wxgui_fftsink2_0_0_1_0_0 = fftsink2.fft_sink_f( self.notebook.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=4096, fft_rate=15, average=False, avg_alpha=None, title='filtro pasa altas', peak_hold=False, win=window.flattop, ) self.notebook.GetPage(1).Add(self.wxgui_fftsink2_0_0_1_0_0.win) self.wxgui_fftsink2_0_0_1_0 = fftsink2.fft_sink_f( self.notebook.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=4096, fft_rate=15, average=False, avg_alpha=None, title='filtro pasa bajas', peak_hold=False, win=window.flattop, ) self.notebook.GetPage(0).Add(self.wxgui_fftsink2_0_0_1_0.win) self.lp_filter = filter.fir_filter_fff(1, (lp_taps)) self.lp_filter.declare_sample_delay(0) self.hp_filter = filter.fir_filter_fff(1, (hp_taps)) self.hp_filter.declare_sample_delay(0) self.bp_filter = filter.fir_filter_fff(1, (bp_taps)) self.bp_filter.declare_sample_delay(0) self.blocks_throttle_0_1_0_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0_1_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f( analog.GR_GAUSSIAN, 1, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.bp_filter, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.hp_filter, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.lp_filter, 0)) self.connect((self.blocks_throttle_0_1, 0), (self.wxgui_fftsink2_0_0_1_0, 0)) self.connect((self.blocks_throttle_0_1_0, 0), (self.wxgui_fftsink2_0_0_1_0_0, 0)) self.connect((self.blocks_throttle_0_1_0_0, 0), (self.wxgui_fftsink2_0_0_1_0_1, 0)) self.connect((self.bp_filter, 0), (self.blocks_throttle_0_1_0_0, 0)) self.connect((self.hp_filter, 0), (self.blocks_throttle_0_1_0, 0)) self.connect((self.lp_filter, 0), (self.blocks_throttle_0_1, 0))