コード例 #1
0
ファイル: qa_fastnoise.py プロジェクト: zhoulm1901/gnuradio
 def test_003_cmplx_gaussian_pool(self):
     src = analog.fastnoise_source_c(type=analog.GR_GAUSSIAN,
                                     **self.default_args)
     src2 = analog.fastnoise_source_c(type=analog.GR_GAUSSIAN,
                                      **self.default_args)
     self.assertTrue(
         numpy.array_equal(numpy.array(src.samples()),
                           numpy.array(src2.samples())))
コード例 #2
0
ファイル: qa_fastnoise.py プロジェクト: zhoulm1901/gnuradio
 def test_003_cmplx_uniform_pool(self):
     src = analog.fastnoise_source_c(type=analog.GR_UNIFORM,
                                     **self.default_args)
     src2 = analog.fastnoise_source_c(type=analog.GR_UNIFORM,
                                      **self.default_args)
     self.assertTrue(
         numpy.array_equal(numpy.array(src.samples()),
                           numpy.array(src2.samples())))
コード例 #3
0
def test_noise_source_complex():
    top = gr.top_block()
    src = analog.fastnoise_source_c(analog.GR_UNIFORM, math.sqrt(2))
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, probe)

    return top, probe
コード例 #4
0
def test_noise_source_complex():
    top = gr.top_block()
    src = analog.fastnoise_source_c(analog.GR_UNIFORM, math.sqrt(2))
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, probe)

    return top, probe
コード例 #5
0
def test_pll_refout_cc():
    top = gr.top_block()
    src = analog.fastnoise_source_c(analog.GR_UNIFORM, math.sqrt(2))
    pll = analog.pll_refout_cc(2*math.pi*1e3/300e3, 2*math.pi*200e3/300e3, 2*math.pi*220e3/300)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, pll, probe)

    return top, probe
コード例 #6
0
def test_pll_refout_cc():
    top = gr.top_block()
    src = analog.fastnoise_source_c(analog.GR_UNIFORM, math.sqrt(2))
    pll = analog.pll_refout_cc(2*math.pi*1e3/300e3, 2*math.pi*200e3/300e3, 2*math.pi*220e3/300)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, pll, probe)

    return top, probe
コード例 #7
0
def noise(noise_amp):
    '''
    function to create and return a GNURadio source block that outputs constant 0s
    :param noise_amp: variance of noise amplitude for the desired SNR
    :type noise_amp: float

    :return : block that produces a random vector of 8192 floats with mean 0 and variance noise_amp
    :return type: GNURadio blocks.vector_source_b block
    '''
    return analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192)
コード例 #8
0
ファイル: qa_fastnoise.py プロジェクト: danbar/gnuradio
 def run_test_complex(self, form):
     """ Run test case with complex input/output
     """
     tb = gr.top_block()
     src = analog.fastnoise_source_c(type=form, **self.default_args)
     head = blocks.head(nitems=self.num_items, sizeof_stream_item=gr.sizeof_gr_complex)
     sink = blocks.vector_sink_c()
     tb.connect(src, head, sink)
     tb.run()
     return numpy.array(sink.data())
コード例 #9
0
ファイル: qa_fastnoise.py プロジェクト: zhoulm1901/gnuradio
 def run_test_complex(self, form):
     """ Run test case with complex input/output
     """
     tb = gr.top_block()
     src = analog.fastnoise_source_c(type=form, **self.default_args)
     head = blocks.head(nitems=self.num_items,
                        sizeof_stream_item=gr.sizeof_gr_complex)
     sink = blocks.vector_sink_c()
     tb.connect(src, head, sink)
     tb.run()
     return numpy.array(sink.data())
コード例 #10
0
ファイル: bm_noise.py プロジェクト: phi-psi/gr-benchmark
    def run_fastnoise_source_c(self):
        ntype = analog.GR_GAUSSIAN
        ampl = 10
        seed = 0

        self.blocks = []
        self.tb = gr.top_block()
        self.blocks.append(analog.fastnoise_source_c(ntype, ampl, seed))
        self.blocks.append(blocks.head(gr.sizeof_gr_complex, self.N))
        self.blocks.append(blocks.null_sink(gr.sizeof_gr_complex))
        self.tb.connect(*self.blocks)
        self.tb.run()
コード例 #11
0
ファイル: bm_noise.py プロジェクト: WindyCitySDR/gr-ofdm
    def run_fastnoise_source_c(self):
        ntype = analog.GR_GAUSSIAN
        ampl = 10
        seed = 0

        self.blocks = []
        self.tb = gr.top_block()
        self.blocks.append(analog.fastnoise_source_c(ntype, ampl, seed))
        self.blocks.append(blocks.head(gr.sizeof_gr_complex, self.N))
        self.blocks.append(blocks.null_sink(gr.sizeof_gr_complex))
        self.tb.connect(*self.blocks)
        self.tb.run()
コード例 #12
0
    def __init__(self, dtype="discrete", limit=10000, randomize=False):
        if dtype == "discrete":
            gr.hier_block2.__init__(self, "source_alphabet",
                                    gr.io_signature(0, 0, 0),
                                    gr.io_signature(1, 1, gr.sizeof_char))

            self.src = blocks.file_source(
                gr.sizeof_char, "source_material/gutenberg_shakespeare.txt")
            self.convert = blocks.packed_to_unpacked_bb(1, gr.GR_LSB_FIRST)
            # self.convert = blocks.packed_to_unpacked_bb(8, gr.GR_LSB_FIRST);
            self.limit = blocks.head(gr.sizeof_char, limit)
            self.connect(self.src, self.convert)
            last = self.convert

            # whiten our sequence with a random block scrambler (optionally)
            if randomize:
                rand_len = 256
                rand_bits = np.random.randint(2, size=rand_len)
                self.rand_src = blocks.vector_source_b(rand_bits, True)
                self.xor = blocks.xor_bb()
                self.connect(self.rand_src, (self.xor, 1))
                self.connect(last, self.xor)
                last = self.xor
        elif dtype == "continuous":  # continuous
            gr.hier_block2.__init__(self, "source_alphabet",
                                    gr.io_signature(0, 0, 0),
                                    gr.io_signature(1, 1, gr.sizeof_float))

            self.src = blocks.wavfile_source(
                "source_material/serial-s01-e01.mp3", True)
            self.float_short = blocks.float_to_short(1, 1)
            self.convert2 = blocks.interleaved_short_to_complex()
            self.convert3 = blocks.multiply_const_cc(1.0 / 65535)
            self.convert = blocks.complex_to_float()
            self.limit = blocks.head(gr.sizeof_float, limit)
            self.connect(self.src, self.convert2, self.convert3, self.convert)
            last = self.convert
        else:  # noise
            gr.hier_block2.__init__(
                self, "source_alphabet", gr.io_signature(0, 0, 0),
                gr.io_signature(1, 1, gr.sizeof_gr_complex))

            self.src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1e-4, 0,
                                                 8192)
            self.limit = blocks.head(gr.sizeof_gr_complex, limit)
            last = self.src

        # connect head or not, and connect to output
        if limit is None:
            self.connect(last, self)
        else:
            self.connect(last, self.limit, self)
コード例 #13
0
 def test_with_noise(self):
     # set up fg
     noise = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 8192)
     head = blocks.head(gr.sizeof_gr_complex * 1, 2048)
     rcvr = flex_receiver(0, 50e3)
     msgsink = blocks.message_debug()
     self.tb.connect((noise, 0), (head, 0))
     self.tb.connect((head, 0), (rcvr, 0))
     self.tb.msg_connect((rcvr, 'pages'), (msgsink, 'store'))
     self.tb.run()
     # No data is expected to be output, this merely tests that a noise source won't crash any
     # of the pieces which are knit together with the flex_receiver heir block.
     self.assertEqual(0, msgsink.num_messages())
コード例 #14
0
ファイル: zammer.py プロジェクト: FFY00/rfofthings
    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 = 50e6
        self.freq = freq = 915e6

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(75, 0)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 1, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.uhd_usrp_sink_0, 0))
コード例 #15
0
    def __init__(self, values, snr_reference):
        gr.hier_block2.__init__(
            self,
            "snr_usrp_sink",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(0, 0, 0),
        )

        noise_amp = 10**(-values['snr'] / (snr_reference * 20.0))

        self.add = blocks.add_vcc(1)
        self.noise_source = analog.fastnoise_source_c(analog.GR_GAUSSIAN,
                                                      noise_amp, 0, 8192)
        self.u = usrp_sink(values)

        self.connect(self.noise_source, (self.add, 0), self.u)
        self.connect(self, (self.add, 1))
コード例 #16
0
    def __init__(self, snr, snr_reference, sink_file):
        gr.hier_block2.__init__(
            self,
            "snr_head_file",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(0, 0, 0),
        )
        noise_amp = 10**(-snr / (snr_reference * 20.0))

        self.head = blocks.head(gr.sizeof_gr_complex * 1, 1024)
        self.skiphead = blocks.skiphead(gr.sizeof_gr_complex * 1, 10000)
        self.file_sink = blocks.file_sink(gr.sizeof_gr_complex * 1, sink_file,
                                          False)
        self.file_sink.set_unbuffered(False)
        self.add = blocks.add_vcc(1)
        self.noise_source = analog.fastnoise_source_c(analog.GR_GAUSSIAN,
                                                      noise_amp, 0, 8192)

        self.connect(self.noise_source, (self.add, 0), self.skiphead,
                     self.head, self.file_sink)
        self.connect(self, (self.add, 1))
コード例 #17
0
ファイル: test_data_gen.py プロジェクト: gr-sp/gr-eventsim
    def __init__(self):
        gr.top_block.__init__(self, "Test Data Gen")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 25e6

        ##################################################
        # Blocks
        ##################################################
        self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, int(samp_rate*10))
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "test.dat", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_head_0, 0))    
        self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0))    
コード例 #18
0
    def __init__(self, args):
        gr.top_block.__init__(self, "Generate File", catch_exceptions=True)

        ##################################################
        # Variables
        ##################################################
        nsamples = args.samples
        filename = args.filename

        ##################################################
        # Blocks
        ##################################################
        hd = blocks.head(gr.sizeof_gr_complex * 1, 100000000)

        src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 8192)

        snk = blocks.file_sink(gr.sizeof_gr_complex * 1, filename, False)
        snk.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((src, 0), (hd, 0), (snk, 0))
コード例 #19
0
    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))
コード例 #20
0
ファイル: per_test.py プロジェクト: cschmol/gr-inets
    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.sps = sps = 4
        self.range_tx_gain = range_tx_gain = 15
        self.range_rx_gain = range_rx_gain = 18
        self.range_mu = range_mu = 0.4
        self.range_freq = range_freq = 3.5e9
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = "{:2.1f} GHz".format(float((77e9-range_freq))/1e9)
        self.tx_gain = tx_gain = range_tx_gain
        self.threshold = threshold = 50
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = range_rx_gain
        
        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)
          
        self.range_noise = range_noise = 0
        self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base()
        self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.mu = mu = range_mu
        self.freq = freq = range_freq
        self.diff_preamble_256 = diff_preamble_256 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128]
        self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "TX")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "RX")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Demod")
        self.top_layout.addWidget(self.tab)
        self._range_noise_range = Range(0, 0.1, 0.005, 0, 200)
        self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, "noise", "counter_slider", float)
        self.top_layout.addWidget(self._range_noise_win)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)
        
        if None:
          self._variable_qtgui_label_0_formatter = None
        else:
          self._variable_qtgui_label_0_formatter = lambda x: x
        
        self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel("RF Frequency"+": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 0,1,1,1)
          
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq+100e6, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self._range_tx_gain_range = Range(0, 15, 1, 15, 200)
        self._range_tx_gain_win = RangeWidget(self._range_tx_gain_range, self.set_range_tx_gain, "Tx Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_tx_gain_win, 1,1,1,1)
        self._range_rx_gain_range = Range(0, 60, 1, 18, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1)
        self._range_mu_range = Range(0, 1, 0.01, 0.4, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1)
        self._range_freq_range = Range(2.5e9, 4e9, 100e6, 3.5e9, 200)
        self._range_freq_win = RangeWidget(self._range_freq_range, self.set_range_freq, "IF Frequency", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_freq_win, 0,0,1,1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	256, #size
        	1, #samp_rate
        	"Frequency Offset", #name
        	1 #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(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 1, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0_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 = [0, -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_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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	100000, #size
        	samp_rate, #samp_rate
        	"Correlation", #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, 200)
        
        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_NORM, qtgui.TRIG_SLOPE_POS, 20, 0, 1, "")
        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_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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	128, #size
        	"Payload", #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_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, "fd")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(True)
        
        if not True:
          self.qtgui_const_sink_x_0_0.disable_legend()
        
        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 xrange(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.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.inets_radio_0 = inets_radio(
            constellation=qpsk_mod,
            matched_filter_coeff=rrc,
            mu=mu,
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            threshold=threshold,
        )
        self.inets_per_logger_0 = inets.per_logger()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((range_noise, ))
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 1024)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_radio_0, 'in'))    
        self.msg_connect((self.inets_radio_0, 'out'), (self.inets_per_logger_0, 'payload_in'))    
        self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_per_logger_0, 'snr_in'))    
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_add_xx_0, 0), (self.inets_radio_0, 0))    
        self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.inets_radio_0, 2), (self.blocks_complex_to_mag_0, 0))    
        self.connect((self.inets_radio_0, 1), (self.blocks_complex_to_mag_0_0, 0))    
        self.connect((self.inets_radio_0, 5), (self.blocks_null_sink_0, 0))    
        self.connect((self.inets_radio_0, 6), (self.blocks_null_sink_0_0, 0))    
        self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0))    
        self.connect((self.inets_radio_0, 4), (self.qtgui_time_sink_x_0_0, 0))    
        self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_add_xx_0, 0))    
コード例 #21
0
    def __init__(self, M=1024, K=4, syms_per_frame=10, exclude_multipath=0, sel_taps=0, freq_offset=0, exclude_noise=0, sel_noise_type=0, SNR=20, exclude_preamble=0, sel_preamble=0, zero_pads=1, extra_pad=False):
        gr.hier_block2.__init__(self,
            "fbmc_channel_hier_cc",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.freq_offset = freq_offset
        self.sel_noise_type = sel_noise_type
        self.sel_taps = sel_taps
        self.SNR = SNR
        self.exclude_multipath = exclude_multipath
        self.exclude_noise = exclude_noise
        self.exclude_preamble = exclude_preamble
        self.K = K
        self.M = M
        self.syms_per_frame = syms_per_frame
        self.zero_pads =zero_pads

        ##################################################
        # Variables
        ##################################################
        self.taps = taps = (1)
        if sel_taps == 0: #epa
            self.taps = taps = (0.998160541385960,0.0605566335500750,0.00290305927764350)
        elif sel_taps == 1: #eva
            self.taps = taps = (0.748212004186014,0.317358833370450,0.572776845645705,0,0.0538952624324030,0.0874078808126807,0,0,0,0.0276407988816600,0,0,0,0.00894438719057275)
        elif sel_taps ==2: #etu
            self.taps = taps = (0.463990169152204,0.816124099344485,0,0.292064507384192,0,0,0,0,0.146379002496595,0,0,0,0.0923589067029112,0,0,0,0,0,0,0,0,0,0,0,0,0.0582745305123628)
        
        self.noise_type = analog.GR_GAUSSIAN
        if sel_noise_type == 200:
            self.noise_type = analog.GR_UNIFORM
        elif sel_noise_type ==201:
            self.noise_type = analog.GR_GAUSSIAN
        elif sel_noise_type == 202:
            self.noise_type = analog.GR_LAPLACIAN
        elif sel_noise_type ==203:
            self.noise_type = analog.GR_IMPULSE

        if sel_preamble == 0: # standard one vector center preamble [1,-j,-1,j]
            self.num_center_vectors = num_center_vectors = 1
        elif sel_preamble == 1: # standard preamble with triple repetition
            self.num_center_vectors = num_center_vectors = 3
        elif sel_preamble ==2: # IAM-R preamble [1, -1,-1, 1]
            self.num_center_vectors = num_center_vectors = 1
        else: # standard one vector center preamble [1,-j,-1,j]
            self.num_center_vectors = num_center_vectors = 1

        if extra_pad:
            self.total_zeros = total_zeros = 1+2*zero_pads
        else:
            self.total_zeros = total_zeros = 2*zero_pads

        

        # normalizing factor to be added if normalization takes place in transmitter
        self.normalizing_factor = float(1)/(M*.6863)
        if exclude_preamble:
            self.amp = self.normalizing_factor*math.sqrt((10**(float(-1*SNR)/10))*(2*K*M+(2*syms_per_frame-1)*M)/(4*syms_per_frame))/math.sqrt(2)
        else:
            syms_per_frame_2 = syms_per_frame + (self.num_center_vectors+self.total_zeros)/2
            self.amp = self.normalizing_factor*math.sqrt((10**(float(-1*SNR)/10))*(M*(syms_per_frame+self.num_center_vectors)/(syms_per_frame+self.num_center_vectors+self.total_zeros))*((K*M+(2*syms_per_frame_2-1)*M/2)/(M*syms_per_frame_2)))/math.sqrt(2)
            # self.amp = self.normalizing_factor*math.sqrt((10**(float(-1*SNR)/10))*(M*(syms_per_frame+self.num_center_vectors)/(syms_per_frame+self.num_center_vectors+self.total_zeros))*((K*M+(2*syms_per_frame-1)*M/2)/(M*syms_per_frame)))/math.sqrt(2)

        ##################################################
        # Blocks
        ##################################################
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0.0,
            frequency_offset=freq_offset,
            epsilon=1.0,
            taps=taps,
            noise_seed=0,
            block_tags=False
        )
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blks2_selector_1 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex*1,
            num_inputs=2,
            num_outputs=1,
            input_index=exclude_noise,
            output_index=0,
        )
        self.blks2_selector_0 = grc_blks2.selector(
            item_size=gr.sizeof_gr_complex*1,
            num_inputs=2,
            num_outputs=1,
            input_index=exclude_multipath,
            output_index=0,
        )
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(self.noise_type, self.amp, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.channels_channel_model_0, 0))
        self.connect((self, 0), (self.blks2_selector_0, 1))
        self.connect((self.channels_channel_model_0, 0), (self.blks2_selector_0, 0))
        self.connect((self.blks2_selector_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blks2_selector_1, 0))
        self.connect((self.blocks_null_source_0, 0), (self.blks2_selector_1, 1))
        self.connect((self.blks2_selector_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self, 0))
コード例 #22
0
	def sim ( self, arity, snr_db, N ):
		M = 1024
		theta_sel = 0
		syms_per_frame = 20
		zero_pads = 1
		# center_preamble = [1, -1j, -1, 1j] # assumed to be normalized to 1
		qam_size = 2**arity
		# preamble = [0]*M*zero_pads+center_preamble*((int)(M/len(center_preamble)))+[0]*M*zero_pads
		# print preamble
		# num_symbols = 2**12
		exclude_preamble = 1
		exclude_multipath = 1
		sel_taps = 2 # epa=0, eva = 1, etu=2
		freq_offset= 0
		exclude_noise = 0
		sel_noise_type =0 # gaussian
		eq_select = 0 # 0=1-tap 1=3-taps w/linear intrp 2=3-taps w/ geo. intrp. 3= no eq.
		carriers = M
		sel_preamble = 0 # 0: IAM-C 1: IAM-C with 3 rep. 2: IAM-R
		extra_pad=False
		# SNR = 20
		K = 4
		N = int( N ) # num of !samples!
		num_bits = N*arity
		normalizing_factor = float(1)/(M*.6863)#*.6863)
		# print normalizing_factor
		# amp = math.sqrt(M/(10**(float(snr_db)/10)))/math.sqrt(2)
		# amp = math.sqrt((10**(float(-1*snr_db)/20))*(2*K*M+(2*syms_per_frame-1)*M)/(4*syms_per_frame))/math.sqrt(2)
		if exclude_preamble:
			amp = normalizing_factor*math.sqrt((10**(float(-1*snr_db)/10))*(2*K*M+(2*syms_per_frame-1)*M)/(4*syms_per_frame))/math.sqrt(2)
			# amp = normalizing_factor*math.sqrt((10**(float(-1*snr_db)/10))*(2*K*M+(2*syms_per_frame-1)*M)/(4*syms_per_frame))/math.sqrt(2)
		else:
			amp = normalizing_factor*math.sqrt((10**(float(-1*snr_db)/10))*(M*(syms_per_frame+1)/(syms_per_frame+1+2*zero_pads))*((K*M+(2*syms_per_frame-1)*M/2)/(M*syms_per_frame)))/math.sqrt(2)
		# print amp
		# print amp2
		taps = (1)
		if sel_taps == 0: #epa
				taps = (0.998160541385960,0.0605566335500750,0.00290305927764350)
		elif sel_taps == 1: #eva
				taps = (0.748212004186014,0.317358833370450,0.572776845645705,0,0.0538952624324030,0.0874078808126807,0,0,0,0.0276407988816600,0,0,0,0.00894438719057275)
		elif sel_taps ==2: #etu
				taps = (0.463990169152204,0.816124099344485,0,0.292064507384192,0,0,0,0,0.146379002496595,0,0,0,0.0923589067029112,0,0,0,0,0,0,0,0,0,0,0,0,0.0582745305123628)
		tx = ofdm.fbmc_transmitter_hier_bc(M, K, qam_size, syms_per_frame, carriers, theta_sel, exclude_preamble, sel_preamble,zero_pads,extra_pad)
		rx = ofdm.fbmc_receiver_hier_cb(M, K, qam_size, syms_per_frame, carriers, theta_sel, eq_select, exclude_preamble, sel_preamble, zero_pads,extra_pad)
				# def __init__(self, M=1024, K=4, qam_size=16, syms_per_frame=10, carriers=924, theta_sel=0, sel_eq=0, exclude_preamble=0, sel_preamble=0, zero_pads=1, extra_pad=False):

		# ch = ofdm.fbmc_channel_hier_cc(M, K, syms_per_frame, exclude_multipath, sel_taps, freq_offset, exclude_noise, sel_noise_type, snr_db, exclude_preamble, zero_pads)

		# src = blocks.vector_source_b(src_data, vlen=1)
		xor_block = blocks.xor_bb()
		head1 = blocks.head(gr.sizeof_char*1, N)
		head0 = blocks.head(gr.sizeof_char*1, N)
		add_block = blocks.add_vcc(1)
		src = blocks.vector_source_b(map(int, numpy.random.randint(0, qam_size, 100000)), True)
		noise = analog.fastnoise_source_c(analog.GR_GAUSSIAN, amp, 0, 8192)
		dst = blocks.vector_sink_b(vlen=1)
		# ch_model = channels.channel_model(
		# 				noise_voltage=0.0,
		# 				frequency_offset=freq_offset,
		# 				epsilon=1.0,
		# 				taps=taps,
		# 				noise_seed=0,
		# 				block_tags=False
		# 		)

		tb = gr.top_block ( "test_block" )
		tb.connect((src, 0), (head1, 0)) #esas
		tb.connect((head1, 0), (xor_block, 0)) #esas
		tb.connect((src, 0), (tx, 0)) #esas
		# tb.connect((tx, 0), (add_block, 0)) #esas
		if exclude_multipath:
			tb.connect((tx, 0), (add_block, 0)) #esas
		else:
			tb.connect((tx, 0), (ch_model, 0))
			tb.connect((ch_model, 0), (add_block, 0)) 
		tb.connect((noise, 0), (add_block, 1)) #esas
		tb.connect((add_block, 0), (rx, 0)) #esas
		tb.connect((rx, 0),(head0, 0)) #esas
		tb.connect((head0, 0), (xor_block, 1)) #esas
		tb.connect((xor_block, 0), (dst, 0)) #esas  

		tb.run()

		# what we record in dst.data will be output of xor_block. now we have to process those data
		# so as to find bit errors.
		result_data = dst.data()

		bit_errors = 0
		for i in range(len(result_data)):
			# print bin(result_data[i])
			bit_errors = bit_errors + (bin(result_data[i]).count('1'))

		# print len(result_data)

		# return 1

		return float(bit_errors) / num_bits
コード例 #23
0
ファイル: qa_fastnoise.py プロジェクト: danbar/gnuradio
 def test_003_cmplx_gaussian_pool(self):
     src = analog.fastnoise_source_c(type=analog.GR_GAUSSIAN, **self.default_args)
     src2 = analog.fastnoise_source_c(type=analog.GR_GAUSSIAN, **self.default_args)
     self.assertTrue(numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples())))
コード例 #24
0
ファイル: top_block.py プロジェクト: noahthurston/gr-eve
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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", "top_block")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.snr_db = snr_db = 0
        self.samp_rate = samp_rate = 32000
        self.max_items = max_items = 80

        self.const = const = digital.constellation_calcdist(
            ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()

        ##################################################
        # Blocks
        ##################################################
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            const)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (const.points()), 1)
        self.blocks_vector_sink_x_1 = blocks.vector_sink_b(1)
        self.blocks_vector_sink_x_0 = blocks.vector_sink_b(1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb(
            1, 8, "", False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            1, const.bits_per_symbol(), "", False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            const.bits_per_symbol(), 8, "", False, gr.GR_LSB_FIRST)
        self.blocks_head_0_0 = blocks.head(gr.sizeof_char * 1, max_items)
        self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, max_items)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, 1000000)), True)
        self.analog_fastnoise_source_x_0_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 10**(-snr_db / 20.0), 0, 2**16)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 10**(-snr_db / 20.0), 0, 2**16)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.analog_fastnoise_source_x_0_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_repack_bits_bb_1, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_vector_sink_x_0, 0))
        self.connect((self.blocks_head_0_0, 0),
                     (self.blocks_vector_sink_x_1, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_head_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_repack_bits_bb_1, 0),
                     (self.blocks_head_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
コード例 #25
0
ファイル: top_block.py プロジェクト: ofenerci/dspira
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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", "top_block")

        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.vec_length = vec_length = 65536
        self.sinc_sample_locations = sinc_sample_locations = np.arange(-np.pi*4/2.0, np.pi*4/2.0, np.pi/vec_length)
        self.timenow = timenow = datetime.now().strftime("%Y-%m-%d_%H.%M.%S")
        self.sinc = sinc = np.sinc(sinc_sample_locations/np.pi)
        self.prefix = prefix = "/Users/kbandura/grc_data/"
        self.samp_rate = samp_rate = 2.4e6
        self.recfile = recfile = prefix + timenow + ".h5"
        self.integration_time = integration_time = 2
        self.freq = freq = 1420.5e6
        self.display_integration = display_integration = 0.5
        self.custom_window = custom_window = sinc*np.hamming(4*vec_length)

        ##################################################
        # Blocks
        ##################################################
        self.radio_astro_hdf5_sink_1 = radio_astro.hdf5_sink(vec_length, recfile, 'testing', freq - samp_rate/2, samp_rate/vec_length, 'testing')
        self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f(
            vec_length,
            freq - samp_rate/2,
            samp_rate/vec_length,
            "Frequency",
            "PSD",
            "Spectrum",
            1 # Number of inputs
        )
        self.qtgui_vector_sink_f_0.set_update_time(0.10)
        self.qtgui_vector_sink_f_0.set_y_axis(0, 3000)
        self.qtgui_vector_sink_f_0.enable_autoscale(True)
        self.qtgui_vector_sink_f_0.enable_grid(True)
        self.qtgui_vector_sink_f_0.set_x_axis_units("Hz")
        self.qtgui_vector_sink_f_0.set_y_axis_units("arb")
        self.qtgui_vector_sink_f_0.set_ref_level(0)

        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 xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_vector_sink_f_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_vector_sink_f_0.set_line_label(i, labels[i])
            self.qtgui_vector_sink_f_0.set_line_width(i, widths[i])
            self.qtgui_vector_sink_f_0.set_line_color(i, colors[i])
            self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i])

        self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_vector_sink_f_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	vec_length, #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, 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(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(False)
        self.qtgui_time_sink_x_0.enable_control_panel(True)

        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.fft_vxx_0 = fft.fft_vcc(vec_length, True, (window.rectangular(vec_length)), True, 1)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, vec_length)
        self.blocks_stream_to_vector_0_2 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, vec_length, 0)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((custom_window[-vec_length:]))
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((custom_window[2*vec_length:3*vec_length]))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((custom_window[vec_length:2*vec_length]))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((custom_window[0:vec_length]))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(vec_length)
        self.blocks_integrate_xx_0_0 = blocks.integrate_ff(int(display_integration*samp_rate/vec_length), vec_length)
        self.blocks_integrate_xx_0 = blocks.integrate_ff(int((integration_time)*samp_rate/vec_length)/int(display_integration*samp_rate/vec_length), vec_length)
        self.blocks_delay_0_0_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 3*vec_length)
        self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 2*vec_length)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, vec_length)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(vec_length)
        self.blocks_add_xx_0 = blocks.add_vcc(vec_length)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_delay_0_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_delay_0_0_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_delay_0_0_0_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_integrate_xx_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0), (self.blocks_stream_to_vector_0_0, 0))
        self.connect((self.blocks_delay_0_0_0, 0), (self.blocks_stream_to_vector_0_2, 0))
        self.connect((self.blocks_delay_0_0_0_0, 0), (self.blocks_stream_to_vector_0_1, 0))
        self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_integrate_xx_0, 0), (self.radio_astro_hdf5_sink_1, 0))
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_integrate_xx_0, 0))
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 3))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_nlog10_ff_0_0, 0), (self.qtgui_vector_sink_f_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_multiply_const_vxx_0_2, 0))
        self.connect((self.blocks_stream_to_vector_0_0, 0), (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.blocks_stream_to_vector_0_1, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_stream_to_vector_0_2, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
コード例 #26
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 = 32000

        ##################################################
        # Blocks
        ##################################################
        self.tutorial_amp_vector_cc_0 = tutorial.amp_vector_cc(1, 100)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            samp_rate / 8,  #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, 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(True)
        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 * 1):
            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_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            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.tutorial_amp_vector_cc_0, 0))
        self.connect((self.tutorial_amp_vector_cc_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
コード例 #27
0
    def __init__(self, fsk_dev=10000, lpf_cutoff=10e3, lpf_trans=1e3):
        gr.top_block.__init__(self, "Afsk Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Afsk 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", "afsk_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.fsk_dev = fsk_dev
        self.lpf_cutoff = lpf_cutoff
        self.lpf_trans = lpf_trans

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.baud = baud = 1200
        self.samps_per_symb = samps_per_symb = int(samp_rate/baud)
        self.noise_amp = noise_amp = 0.3
        self.mult = mult = (samp_rate)/2/3.141593
        self.decim = decim = 2
        self.bb_gain = bb_gain = .75
        self.alpha = alpha = 0.5

        ##################################################
        # Blocks
        ##################################################
        self._noise_amp_range = Range(0, 1, 0.005, 0.3, 200)
        self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "noise_amp", "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_amp_win, 6,0,1,4)
        self._bb_gain_range = Range(0, 1, .01, .75, 200)
        self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bb_gain_win, 5,0,1,4)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=1,
                decimation=decim,
                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(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not False)

        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(-140, 10)

        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_1 = qtgui.time_sink_f(
        	8192, #size
        	samp_rate, #samp_rate
        	"", #name
        	1 #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(-1, 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(False)
        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(False)
        self.qtgui_time_sink_x_1.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_1.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_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_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	2048, #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, 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(True)
        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)
        self.qtgui_time_sink_x_0.enable_stem_plot(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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4,4,3,4)
        self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim, #bw
        	"RX Spectrum", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_1_0.set_y_axis(-80, 10)
        self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_1_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_1_0.enable_grid(True)
        self.qtgui_freq_sink_x_1_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_1_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_1_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 xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0,4,4,4)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"TX Spectrum", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_1.enable_autoscale(True)
        self.qtgui_freq_sink_x_1.enable_grid(True)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_1.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 xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,4,4)
        self.pyqt_text_output_0 = pyqt.text_output()
        self._pyqt_text_output_0_win = self.pyqt_text_output_0;
        self.top_layout.addWidget(self._pyqt_text_output_0_win)
        self.pyqt_text_input_0 = pyqt.text_input()
        self._pyqt_text_input_0_win = self.pyqt_text_input_0;
        self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 4,0,1,4)
        self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate/decim, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76))
        self.kiss_nrzi_encode_0 = kiss.nrzi_encode()
        self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16)
        self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300)
        self.digital_gfsk_mod_0 = digital.gfsk_mod(
        	samples_per_symbol=samps_per_symb,
        	sensitivity=0.06,
        	bt=1,
        	verbose=False,
        	log=False,
        )
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0)/decim, 0.25*0.175*0.175, 0.25, 0.175, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_tag_gate_0.set_single_key("packet_len")
        self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", '0.0.0.0', '52002', 1024, False)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, ))
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_1 = blocks.add_vcc(1)
        self.audio_sink_0 = audio.sink(samp_rate, '', True)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1700, 1, 0)
        self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate/decim)/(2*math.pi*fsk_dev/8.0))
        self.analog_nbfm_tx_0 = analog.nbfm_tx(
        	audio_rate=samp_rate,
        	quad_rate=samp_rate,
        	tau=75e-6,
        	max_dev=5e3,
        	fh=-1.0,
                )
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_socket_pdu_0_2, 'pdus'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus'))
        self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in'))
        self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_1, 0))
        self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_add_xx_1, 1))
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_add_xx_1, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.blocks_add_xx_1, 0), (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.analog_nbfm_tx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gfsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.kiss_nrzi_encode_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0))
        self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.kiss_nrzi_encode_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
コード例 #28
0
  def __init__ (self, options):
    gr.top_block.__init__(self, "fbmc_benchmark")

    self._bandwidth          = options.bandwidth
    self.servants = []
    self._verbose            = options.verbose

    self._options = copy.copy( options )
    
    self.ideal = options.ideal
    self.ideal2 = options.ideal2
    rms_amp                    = options.rms_amplitude
    
    #Disable OFDM channel estimation preamble -> Still experimental
    options.est_preamble = 0

    self._interpolation = 1

    f1 = numpy.array([-107,0,445,0,-1271,0,2959,0,-6107,0,11953,
                      0,-24706,0,82359,262144/2,82359,0,-24706,0,
                      11953,0,-6107,0,2959,0,-1271,0,445,0,-107],
                      numpy.float64)/262144.

    print "Software interpolation: %d" % (self._interpolation)

    bw = 1.0/self._interpolation
    tb = bw/5
    if self._interpolation > 1:
      self.tx_filter = gr.hier_block2("filter",
                                   gr.io_signature(1,1,gr.sizeof_gr_complex),
                                   gr.io_signature(1,1,gr.sizeof_gr_complex))
      self.tx_filter.connect( self.tx_filter, gr.interp_fir_filter_ccf(2,f1),
                           gr.interp_fir_filter_ccf(2,f1), self.tx_filter )

      print "New"

    else:
      self.tx_filter = None

    self.decimation = 1

    if self.decimation > 1:
      bw = 0.5/self.decimation * 1
      tb = bw/5
      # gain, sampling rate, passband cutoff, stopband cutoff
      # passband ripple in dB, stopband attenuation in dB
      # extra taps
      filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw+tb, 0.1, 60.0, 1)
      print "Software decimation filter length: %d" % (len(filt_coeff))
      self.rx_filter = gr.fir_filter_ccf(self.decimation,filt_coeff)
    else:
      self.rx_filter = None

    self._setup_tx_path(options)
    self._setup_rx_path(options)
    self._setup_rpc_manager()

    config = self.config = station_configuration()


    if options.imgxfer:
      self.rxpath.setup_imgtransfer_sink()

    if not options.no_decoding:
      self.rxpath.publish_rx_performance_measure()

      # capture transmitter's stream to disk
    #self.dst  = gr.file_sink(gr.sizeof_gr_complex,options.to_file)
    self.dst= self.rxpath
    if options.force_rx_filter:
      print "Forcing rx filter usage"
      self.connect( self.rx_filter, self.dst )
      self.dst = self.rx_filter

    if options.ideal or self.ideal2:
       self._amplifier = ofdm.multiply_const_ccf( 1.0 )
       self.connect( self._amplifier, self.dst  )
       self.dst = self._amplifier
       self.set_rms_amplitude(rms_amp)
       
    if options.measure:
      self.m = throughput_measure(gr.sizeof_gr_complex)
      self.connect( self.m, self.dst )
      self.dst = self.m

    
    if options.snr is not None:
      if options.berm is not None:
          #noise_sigma = 0.0001/32767.0
          noise_sigma = 380/32767.0#250/32767.0 #380/32767.0 #empirically given, gives the received SNR range of (1:28) for tx amp. range of (500:10000) which is set in rm_ber_measurement.py
          #check for fading channel
      else:
          snr_db = options.snr
          snr = 10.0**(snr_db/10.0)
          noise_sigma = sqrt( config.rms_amplitude**2 / snr )

      print " Noise St. Dev. %d" % (noise_sigma)
      awgn_chan = blocks.add_cc()
      #awgn_noise_src = ofdm.complex_white_noise( 0.0, noise_sigma )
      #noise_sigma = 0.000000000001
      awgn_noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma, 0, 8192)
      self.connect( awgn_noise_src, (awgn_chan,1) )
      self.connect( awgn_chan,self.dst )
      #self.connect( awgn_chan, blocks.skiphead( gr.sizeof_gr_complex, 3* config.fft_length ),self.dst )
      self.dst = awgn_chan
      


    if options.freqoff is not None:
      freq_off = self.freq_off = channel.freq_offset(options.freqoff )
      dst = self.dst
      self.connect(freq_off, dst) 
      self.dst = freq_off
      self.rpc_mgr_tx.add_interface("set_freq_offset",self.freq_off.set_freqoff)
      #log_to_file( self, self.freq_off, "data/TRANSMITTER_OUT.compl" )



    if options.multipath:
      if options.itu_channel:
        self.fad_chan = channel.itpp_channel(options.bandwidth)
        self.rpc_mgr_tx.add_interface("set_channel_profile",self.fad_chan.set_channel_profile)
      else:
        #self.fad_chan = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j])
        # filter coefficients for the lab exercise
        self.fad_chan = filter.fir_filter_ccc(1,[0,0,0.3267,0.8868,0.3267])

      self.connect(self.fad_chan, self.dst)
      self.dst = self.fad_chan

    if options.samplingoffset is not None:
      soff = options.samplingoffset
      interp = moms(1000000*(1.0+soff),1000000)
      self.connect( interp, self.dst )
      self.dst = interp

      if options.record:
       log_to_file( self, interp, "data/interp_out.compl" )

    tmm =blocks.throttle(gr.sizeof_gr_complex,1e6)
    self.connect( tmm, self.dst )
    self.dst = tmm
    if options.force_tx_filter:
      print "Forcing tx filter usage"
      self.connect( self.tx_filter, self.dst )
      self.dst = self.tx_filter
    if options.record:
      log_to_file( self, self.txpath, "data/txpath_out.compl" )

    if options.scatterplot:
      print "Scatterplot enabled"

    self.connect( self.txpath,self.dst )
    #log_to_file( self, self.txpath, "data/fbmc_rx_input.compl" )



    print "Hit Strg^C to terminate"

    print "Hit Strg^C to terminate"


    # Display some information about the setup
    if self._verbose:
        self._print_verbage()
コード例 #29
0
ファイル: noise_wf.py プロジェクト: mkhuthir/sdr
    def __init__(self):
        gr.top_block.__init__(self, "Noise Waterfall")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Noise Waterfall")
        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", "noise_wf")

        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.bandwidth = bandwidth = 8000000
        self.samp_rate = samp_rate = 4096
        self.ftt_size = ftt_size = 4096
        self.freq = freq = 1000000
        self.center_freq = center_freq = bandwidth / 2
        self.amp = amp = 0.1

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            ftt_size,  #size
            firdes.WIN_HAMMING,  #wintype
            center_freq,  #fc
            bandwidth,  #bw
            '',  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        self.qtgui_waterfall_sink_x_0.disable_legend()

        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 range(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(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 1,
                                       0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            ftt_size,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            center_freq,  #fc
            bandwidth,  #bw
            '',  #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.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "green", "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, 0, 0, 1,
                                       1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_UNIFORM, amp, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
コード例 #30
0
    def __init__(self):
        gr.top_block.__init__(self, "Fm Sine")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Sine")
        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", "fm_sine")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.f_m = f_m = 1e3
        self.delta_f = delta_f = 5e3
        self.samp_rate = samp_rate = 800000
        self.B_T = B_T = 2 * (delta_f + f_m)
        self.sensitivity = sensitivity = 2 * math.pi * delta_f / samp_rate
        self.info_taps = info_taps = firdes.low_pass_2(
            1, samp_rate, f_m, f_m / 8, 60, firdes.WIN_BLACKMAN_hARRIS)
        self.filt_taps = filt_taps = firdes.low_pass_2(
            1, samp_rate, B_T / 2, B_T / 12, 60, firdes.WIN_BLACKMAN_hARRIS)

        ##################################################
        # Blocks
        ##################################################
        self._f_m_range = Range(100, 60e3, 100, 1e3, 200)
        self._f_m_win = RangeWidget(self._f_m_range, self.set_f_m,
                                    'Highest Signal Freq.', "counter_slider",
                                    float)
        self.top_grid_layout.addWidget(self._f_m_win, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            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(0.01)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        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(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 2,
                                       1, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.1)
        self.qtgui_time_sink_x_0.set_y_axis(-1.1, 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(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 = [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:
                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, 1, 0, 1,
                                       2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0.set_y_axis(-160, 0)
        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(0.1)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "magenta", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 0.5, 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_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, 2, 0, 1,
                                       1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._delta_f_range = Range(1e3, 100e3, 1e3, 5e3, 200)
        self._delta_f_win = RangeWidget(self._delta_f_range, self.set_delta_f,
                                        'Max Freq Dev', "counter_slider",
                                        float)
        self.top_grid_layout.addWidget(self._delta_f_win, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1,
                                                 samp_rate / 10, True)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, f_m, 0.5, 0)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            sensitivity)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 0.0, 0, 8192)
        self._B_T_tool_bar = Qt.QToolBar(self)

        if None:
            self._B_T_formatter = None
        else:
            self._B_T_formatter = lambda x: eng_notation.num_to_str(x)

        self._B_T_tool_bar.addWidget(Qt.QLabel('Bandwidth' + ": "))
        self._B_T_label = Qt.QLabel(str(self._B_T_formatter(self.B_T)))
        self._B_T_tool_bar.addWidget(self._B_T_label)
        self.top_grid_layout.addWidget(self._B_T_tool_bar, 3, 0, 1, 1)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_frequency_modulator_fc_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_throttle_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_add_xx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.analog_frequency_modulator_fc_0, 0))
コード例 #31
0
    def __init__(self):
        gr.top_block.__init__(self, "Filtering")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Filtering")
        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", "filtering")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

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

        ##################################################
        # Blocks
        ##################################################
        self._freq_range = Range(-100e3, 100e3, 100, 10e3, 200)
        self._freq_win = RangeWidget(self._freq_range, self.set_freq,
                                     'Frequency', "counter_slider", float)
        self.top_layout.addWidget(self._freq_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            4  #number of inputs
        )
        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(True)
        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(True)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = [
            'Unfiltered', 'Low Pass', 'High Pass', 'Band Pass', '', '', '', '',
            '', ''
        ]
        widths = [2, 2, 2, 2, 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 xrange(4):
            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_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 20e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.high_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.high_pass(1, samp_rate, 20e3, 1e3, firdes.WIN_HAMMING,
                             6.76))
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.band_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.band_pass(1, samp_rate, 30e3, 60e3, 1e3, firdes.WIN_HAMMING,
                             6.76))
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freq, 1, 0)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 0.01, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.band_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0, 3))
        self.connect((self.blocks_add_xx_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.high_pass_filter_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.high_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0, 2))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
コード例 #32
0
ファイル: top_block.py プロジェクト: Notou/gr-learning
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        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", "top_block")

        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 = 1000000
        self.frame_size = frame_size = 100
        self.add = add = 0

        ##################################################
        # Blocks
        ##################################################
        self._add_range = Range(-10, 10, 0.01, 0, 200)
        self._add_win = RangeWidget(self._add_range, self.set_add, 'add', "counter_slider", float)
        self.top_grid_layout.addWidget(self._add_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            2000, #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(False)
        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 = ['', '', '', '', '',
            '', '', '', '', '']
        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:
                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.learning_tag_numerotation_0 = learning.tag_numerotation('step', frame_size, "cc")
        self.learning_sync_rl_preprocessor_0 = learning.sync_rl_preprocessor(frame_size, 20, 4, add, 1e-2)
        self.learning_error_estimator_0 = learning.error_estimator('step', frame_size, "cc", 10)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_add_const_vxx_0 = blocks.add_const_cc(add + (add*1j))
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 1, 0, 8192)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.learning_error_estimator_0, 'error'), (self.learning_sync_rl_preprocessor_0, 'error'))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.learning_tag_numerotation_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.learning_sync_rl_preprocessor_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.learning_error_estimator_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.learning_sync_rl_preprocessor_0, 0), (self.learning_error_estimator_0, 1))
        self.connect((self.learning_sync_rl_preprocessor_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.learning_tag_numerotation_0, 0), (self.blocks_throttle_0, 0))
コード例 #33
0
    def sim(self, arity, snr_db, N):
        M = 1024
        theta_sel = 0
        syms_per_frame = 20
        zero_pads = 1
        # center_preamble = [1, -1j, -1, 1j] # assumed to be normalized to 1
        qam_size = 2**arity
        # preamble = [0]*M*zero_pads+center_preamble*((int)(M/len(center_preamble)))+[0]*M*zero_pads
        # print preamble
        # num_symbols = 2**12
        exclude_preamble = 1
        exclude_multipath = 1
        sel_taps = 2  # epa=0, eva = 1, etu=2
        freq_offset = 0
        exclude_noise = 0
        sel_noise_type = 0  # gaussian
        eq_select = 0  # 0=1-tap 1=3-taps w/linear intrp 2=3-taps w/ geo. intrp. 3= no eq.
        carriers = M
        sel_preamble = 0  # 0: IAM-C 1: IAM-C with 3 rep. 2: IAM-R
        extra_pad = False
        # SNR = 20
        K = 4
        N = int(N)  # num of !samples!
        num_bits = N * arity
        normalizing_factor = float(1) / (M * .6863)  #*.6863)
        # print normalizing_factor
        # amp = math.sqrt(M/(10**(float(snr_db)/10)))/math.sqrt(2)
        # amp = math.sqrt((10**(float(-1*snr_db)/20))*(2*K*M+(2*syms_per_frame-1)*M)/(4*syms_per_frame))/math.sqrt(2)
        if exclude_preamble:
            amp = normalizing_factor * math.sqrt(
                (10**(float(-1 * snr_db) / 10)) *
                (2 * K * M + (2 * syms_per_frame - 1) * M) /
                (4 * syms_per_frame)) / math.sqrt(2)
            # amp = normalizing_factor*math.sqrt((10**(float(-1*snr_db)/10))*(2*K*M+(2*syms_per_frame-1)*M)/(4*syms_per_frame))/math.sqrt(2)
        else:
            amp = normalizing_factor * math.sqrt(
                (10**(float(-1 * snr_db) / 10)) *
                (M * (syms_per_frame + 1) /
                 (syms_per_frame + 1 + 2 * zero_pads)) *
                ((K * M + (2 * syms_per_frame - 1) * M / 2) /
                 (M * syms_per_frame))) / math.sqrt(2)
        # print amp
        # print amp2
        taps = (1)
        if sel_taps == 0:  #epa
            taps = (0.998160541385960, 0.0605566335500750, 0.00290305927764350)
        elif sel_taps == 1:  #eva
            taps = (0.748212004186014, 0.317358833370450, 0.572776845645705, 0,
                    0.0538952624324030, 0.0874078808126807, 0, 0, 0,
                    0.0276407988816600, 0, 0, 0, 0.00894438719057275)
        elif sel_taps == 2:  #etu
            taps = (0.463990169152204, 0.816124099344485, 0, 0.292064507384192,
                    0, 0, 0, 0, 0.146379002496595, 0, 0, 0, 0.0923589067029112,
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0582745305123628)
        tx = ofdm.fbmc_transmitter_hier_bc(M, K, qam_size, syms_per_frame,
                                           carriers, theta_sel,
                                           exclude_preamble, sel_preamble,
                                           zero_pads, extra_pad)
        rx = ofdm.fbmc_receiver_hier_cb(M, K, qam_size, syms_per_frame,
                                        carriers, theta_sel, eq_select,
                                        exclude_preamble, sel_preamble,
                                        zero_pads, extra_pad)
        # def __init__(self, M=1024, K=4, qam_size=16, syms_per_frame=10, carriers=924, theta_sel=0, sel_eq=0, exclude_preamble=0, sel_preamble=0, zero_pads=1, extra_pad=False):

        # ch = ofdm.fbmc_channel_hier_cc(M, K, syms_per_frame, exclude_multipath, sel_taps, freq_offset, exclude_noise, sel_noise_type, snr_db, exclude_preamble, zero_pads)

        # src = blocks.vector_source_b(src_data, vlen=1)
        xor_block = blocks.xor_bb()
        head1 = blocks.head(gr.sizeof_char * 1, N)
        head0 = blocks.head(gr.sizeof_char * 1, N)
        add_block = blocks.add_vcc(1)
        src = blocks.vector_source_b(
            map(int, numpy.random.randint(0, qam_size, 100000)), True)
        noise = analog.fastnoise_source_c(analog.GR_GAUSSIAN, amp, 0, 8192)
        dst = blocks.vector_sink_b(vlen=1)
        # ch_model = channels.channel_model(
        # 				noise_voltage=0.0,
        # 				frequency_offset=freq_offset,
        # 				epsilon=1.0,
        # 				taps=taps,
        # 				noise_seed=0,
        # 				block_tags=False
        # 		)

        tb = gr.top_block("test_block")
        tb.connect((src, 0), (head1, 0))  #esas
        tb.connect((head1, 0), (xor_block, 0))  #esas
        tb.connect((src, 0), (tx, 0))  #esas
        # tb.connect((tx, 0), (add_block, 0)) #esas
        if exclude_multipath:
            tb.connect((tx, 0), (add_block, 0))  #esas
        else:
            tb.connect((tx, 0), (ch_model, 0))
            tb.connect((ch_model, 0), (add_block, 0))
        tb.connect((noise, 0), (add_block, 1))  #esas
        tb.connect((add_block, 0), (rx, 0))  #esas
        tb.connect((rx, 0), (head0, 0))  #esas
        tb.connect((head0, 0), (xor_block, 1))  #esas
        tb.connect((xor_block, 0), (dst, 0))  #esas

        tb.run()

        # what we record in dst.data will be output of xor_block. now we have to process those data
        # so as to find bit errors.
        result_data = dst.data()

        bit_errors = 0
        for i in range(len(result_data)):
            # print bin(result_data[i])
            bit_errors = bit_errors + (bin(result_data[i]).count('1'))

        # print len(result_data)

        # return 1

        return float(bit_errors) / num_bits
コード例 #34
0
    def __init__(self):
        gr.top_block.__init__(self, "Evm Simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Evm Simulation")
        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", "evm_simulation")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.vlen = vlen = 64
        self.samp_rate = samp_rate = 1e6
        self.noise_amp = noise_amp = 0

        ##################################################
        # Blocks
        ##################################################
        self._noise_amp_layout = Qt.QVBoxLayout()
        self._noise_amp_tool_bar = Qt.QToolBar(self)
        self._noise_amp_layout.addWidget(self._noise_amp_tool_bar)
        self._noise_amp_tool_bar.addWidget(Qt.QLabel("Noise Amplitude"+": "))
        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._noise_amp_counter = qwt_counter_pyslot()
        self._noise_amp_counter.setRange(0, 1, 0.01)
        self._noise_amp_counter.setNumButtons(2)
        self._noise_amp_counter.setValue(self.noise_amp)
        self._noise_amp_tool_bar.addWidget(self._noise_amp_counter)
        self._noise_amp_counter.valueChanged.connect(self.set_noise_amp)
        self._noise_amp_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._noise_amp_slider.setRange(0, 1, 0.01)
        self._noise_amp_slider.setValue(self.noise_amp)
        self._noise_amp_slider.setMinimumWidth(200)
        self._noise_amp_slider.valueChanged.connect(self.set_noise_amp)
        self._noise_amp_layout.addWidget(self._noise_amp_slider)
        self.top_layout.addLayout(self._noise_amp_layout)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	1024, #size
        	"", #name
        	2 #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(True)
        
        labels = ["Reference Points", "Received Points", "", "", "",
                  "", "", "", "", ""]
        widths = [2, 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 = [2.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_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_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.cs436_constellation_source_0 = cs436.constellation_source(64, 2)
        self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, vlen)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, vlen)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*vlen, samp_rate,True)
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, vlen)
        self.blocks_add_xx_0 = blocks.add_vcc(vlen)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.cs436_constellation_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_vector_to_stream_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_vector_to_stream_0_0, 0))
        self.connect((self.blocks_vector_to_stream_0_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_vector_to_stream_0, 0), (self.qtgui_const_sink_x_0, 1))
コード例 #35
0
ファイル: stream_usrp.py プロジェクト: denniszollo/peregrine
    def __init__(self, filenames, dev_addrs,
                 onebit, iq, noise, mix, gain, fs, fc, unint, sync_pps):
        gr.top_block.__init__(self)

        if mix:
            raise NotImplementedError("TODO: Hilbert remix mode not implemented.")

        uhd_sinks = [
            uhd.usrp_sink(",".join(
                [addr, "send_frame_size=32768,num_send_frames=128"]),
                          uhd.stream_args(
                              cpu_format="fc32",
                              otwformat="sc8",
                              channels=[0]))
            for addr in dev_addrs]

        for sink in uhd_sinks:
            sink.set_clock_rate(fs*2, uhd.ALL_MBOARDS)
            sink.set_samp_rate(fs)
            sink.set_center_freq(fc, 0)
            sink.set_gain(gain, 0)
            # TODO Use offset tuning?
            if sync_pps:
                sink.set_clock_source("external") # 10 MHz
                sink.set_time_source("external") # PPS

        if unint:
            if noise or onebit or not iq:
                raise NotImplementedError("TODO: RX channel-interleaved mode only "
                                          "supported for noiseless 8-bit complex.")
            
            BLOCK_N=16*1024*1024
            demux = blocks.vector_to_streams(2, len(uhd_sinks))
            self.connect(blocks.file_source(2*len(uhd_sinks)*BLOCK_N, filenames[0], False),
                         blocks.vector_to_stream(2*len(uhd_sinks), BLOCK_N),
                         demux)
            for ix, sink in enumerate(uhd_sinks):
                self.connect((demux, ix),
                             blocks.vector_to_stream(1, 2),
                             blocks.interleaved_char_to_complex(), # [-128.0, +127.0]
                             blocks.multiply_const_cc(1.0/1024), # [-0.125, 0.125)
#                             blocks.vector_to_stream(8, 16*1024),
                             sink)

        else:
            file_srcs = [blocks.file_source(gr.sizeof_char*1, f, False)
                         for f in filenames]

            for src, sink in zip(file_srcs, uhd_sinks):

                if iq:
                    node = blocks.multiply_const_cc(1.0/1024)
                    if onebit:
                        self.connect(src,
                                     blocks.unpack_k_bits_bb(8), 
                                     blocks.char_to_short(), # [0, 1] -> [0, 256]
                                     blocks.add_const_ss(-128), # [-128, +128],
                                     blocks.interleaved_short_to_complex(), # [ -128.0, +128.0]
                                     node) # [-0.125, +0.125]
                    else:
                        self.connect(src, # [-128..127]
                                     blocks.interleaved_char_to_complex(), # [-128.0, +127.0]
                                     node) # [-0.125, +0.125)
                    
                else:
                    node = blocks.float_to_complex(1)
                    if onebit:
                        self.connect(src,
                                     blocks.unpack_k_bits_bb(8), # [0, 1] -> [-0.125, +0.125]
                                     blocks.char_to_float(vlen=1, scale=4),
                                     blocks.add_const_vff((-0.125, )),
                                     node)
                    else:
                        self.connect(src, # [-128..127] -> [-0.125, +0.125)
                                     blocks.char_to_float(vlen=1, scale=1024),
                                     node)
                        
                if noise:
                    combiner = blocks.add_vcc(1)
                    self.connect(node,
                                 combiner,
                                 sink)
                    self.connect(analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise, -222, 8192),
                                 (combiner, 1))
                else:
                    self.connect(node,
                                 sink)

        print "Setting clocks..."
        if sync_pps:
            time.sleep(1.1) # Ensure there's been an edge.  TODO: necessary?
            last_pps_time = uhd_sinks[0].get_time_last_pps()
            while last_pps_time == uhd_sinks[0].get_time_last_pps():
                time.sleep(0.1)
            print "Got edge"
            [sink.set_time_next_pps(uhd.time_spec(round(time.time())+1)) for sink in uhd_sinks]
            time.sleep(1.0) # Wait for edge to set the clocks
        else:
            # No external PPS/10 MHz.  Just set each clock and accept some skew.
            t = time.time()
            [sink.set_time_now(uhd.time_spec(time.time())) for sink in uhd_sinks]
            if len(uhd_sinks) > 1:
                print "Uncabled; loosely synced only. Initial skew ~ %.1f ms" % (
                    (time.time()-t) * 1000)

        t_start = uhd.time_spec(time.time() + 1.5)
        [sink.set_start_time(t_start) for sink in uhd_sinks]
        print "ready"
コード例 #36
0
ファイル: benchmark_ofdm.py プロジェクト: luwangg/gr-ofdm-1
  def __init__ (self, options):
    gr.top_block.__init__(self, "ofdm_benchmark")

    self._bandwidth          = options.bandwidth
    self.servants = []
    self._verbose            = options.verbose

    self._options = copy.copy( options )
    
    self.ideal = options.ideal
    self.ideal2 = options.ideal2
    
    rms_amp                    = options.rms_amplitude

    self._interpolation = 1

    f1 = numpy.array([-107,0,445,0,-1271,0,2959,0,-6107,0,11953,
                      0,-24706,0,82359,262144/2,82359,0,-24706,0,
                      11953,0,-6107,0,2959,0,-1271,0,445,0,-107],
                      numpy.float64)/262144.

    print "Software interpolation: %d" % (self._interpolation)

    bw = 1.0/self._interpolation
    tb = bw/5
    if self._interpolation > 1:
      self.tx_filter = gr.hier_block2("filter",
                                   gr.io_signature(1,1,gr.sizeof_gr_complex),
                                   gr.io_signature(1,1,gr.sizeof_gr_complex))
      self.tx_filter.connect( self.tx_filter, gr.interp_fir_filter_ccf(2,f1),
                           gr.interp_fir_filter_ccf(2,f1), self.tx_filter )

      print "New"

    else:
      self.tx_filter = None

    self.decimation = 1

    if self.decimation > 1:
      bw = 0.5/self.decimation * 1
      tb = bw/5
      # gain, sampling rate, passband cutoff, stopband cutoff
      # passband ripple in dB, stopband attenuation in dB
      # extra taps
      filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw+tb, 0.1, 60.0, 1)
      print "Software decimation filter length: %d" % (len(filt_coeff))
      self.rx_filter = gr.fir_filter_ccf(self.decimation,filt_coeff)
    else:
      self.rx_filter = None

    self._setup_tx_path(options)
    self._setup_rx_path(options)
    self._setup_rpc_manager()

    config = self.config = station_configuration()


    if options.imgxfer:
      self.rxpath.setup_imgtransfer_sink()

    if not options.no_decoding:
      self.rxpath.publish_rx_performance_measure()

      # capture transmitter's stream to disk
    #self.dst  = gr.file_sink(gr.sizeof_gr_complex,options.to_file)
    self.dst= self.rxpath
    if options.force_rx_filter:
      print "Forcing rx filter usage"
      self.connect( self.rx_filter, self.dst )
      self.dst = self.rx_filter
      
    if options.ideal or self.ideal2:
       self._amplifier = ofdm.multiply_const_ccf( 1.0 )
       self.connect( self._amplifier, self.dst  )
       self.dst = self._amplifier
       self.set_rms_amplitude(rms_amp)
       


    if options.measure:
      self.m = throughput_measure(gr.sizeof_gr_complex)
      self.connect( self.m, self.dst )
      self.dst = self.m


    if options.snr is not None:
      if options.berm is not None:
          # empirically determined to reach 30db SNR max in simulation mode
          noise_sigma = 0.0035
      else:
          snr_db = options.snr
          snr = 10.0**(snr_db/10.0)
          noise_sigma = sqrt( config.rms_amplitude**2 / snr )

      print " Noise St. Dev. %f" % (noise_sigma)

      awgn_chan = blocks.add_cc()
      #awgn_noise_src = ofdm.complex_white_noise( 0.0, noise_sigma )
      awgn_noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma, 0, 8192)
      self.connect( awgn_noise_src, (awgn_chan,1) )
      self.connect( awgn_chan, self.dst  )
      self.dst = awgn_chan


    if options.freqoff is not None:
      freq_off = self.freq_off = channel.freq_offset(options.freqoff )
      dst = self.dst
      self.connect(freq_off, dst) 
      self.dst = freq_off
      self.rpc_mgr_tx.add_interface("set_freq_offset",self.freq_off.set_freqoff)


    if options.multipath:
      if options.itu_channel:
        self.fad_chan = channel.itpp_channel(options.bandwidth)
        self.rpc_mgr_tx.add_interface("set_channel_profile",self.fad_chan.set_channel_profile)
        self.rpc_mgr_tx.add_interface("set_norm_doppler",self.fad_chan.set_norm_doppler)
      else:
        #self.fad_chan = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j])
        # filter coefficients for the lab exercise
        self.fad_chan = filter.fir_filter_ccc(1,[0.3267,0.8868,0.3267])
        #self.fad_chan = filter.fir_filter_ccc(1,[0,0,0.1,0.2,0.01,0.3])#0.3267,0.8868,0.3267])
        #self.fad_chan = channels.selective_fading_model(5, 0.1, False, 1, -1, [0, 0, 0], [0.3267,0.8868,0.3267], 10 )
        #self.fad_chan = channels.fading_model(6, 0.05, False);
        #self.fad_chan = channels.dynamic_channel_model(1000000, 0, 0, 0, 0, 3, 0.01, False, 0, [2e-6,4e-6,8e-6],[0.3267,0.8868,0.3267], 20, 0, 0)


      self.connect(self.fad_chan, self.dst)
      self.dst = self.fad_chan

    if options.samplingoffset is not None:
      soff = options.samplingoffset
      interp = moms(1000000*(1.0+soff),1000000)
      #interp = filter.fractional_resampler_cc(0,1000000*(1.0+soff)/1000000.0)
      self.connect( interp, self.dst )
      self.dst = interp

      if options.record:
       log_to_file( self, interp, "data/interp_out.compl" )

    tmm =blocks.throttle(gr.sizeof_gr_complex,options.bandwidth)
    self.connect( tmm, self.dst )
    self.dst = tmm
    if options.force_tx_filter:
      print "Forcing tx filter usage"
      self.connect( self.tx_filter, self.dst )
      self.dst = self.tx_filter
    if options.record:
      log_to_file( self, self.txpath, "data/txpath_out.compl" )


    if options.scatterplot:
      print "Scatterplot enabled"

    self.connect( self.txpath,self.dst )


    print "Hit Strg^C to terminate"

    print "Hit Strg^C to terminate"


    # Display some information about the setup
    if self._verbose:
        self._print_verbage()
コード例 #37
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.RXangle = RXangle = 0
        self.TXangle = TXangle = 0
        self.sps = sps = 4
        self.range_tx_gain = range_tx_gain = 0
        self.range_rx_gain = range_rx_gain = 10
        self.range_mu = range_mu = 0.4
        self.range_freq = range_freq = 2.0e9
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = "{:2.1f} GHz".format(
            float((59e9 + range_freq)) / 1e9)
        self.tx_gain = tx_gain = range_tx_gain
        self.threshold = threshold = 40
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = range_rx_gain

        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps)

        self.range_noise = range_noise = 0
        self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base()
        self.preamble = preamble = [
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0,
            1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1,
            1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
            1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0,
            1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
            1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
            1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
            0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0,
            0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0,
            0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1,
            0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1,
            1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0
        ]
        self.mu = mu = range_mu
        self.freq = freq = range_freq
        self.diff_preamble_256 = diff_preamble_256 = [
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0,
            1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1,
            1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
            1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0,
            1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
            1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
            1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
            0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0,
            0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0,
            0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1,
            0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1,
            1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0
        ]
        self.diff_preamble_128 = diff_preamble_128 = [
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0,
            1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1,
            1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
            1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0,
            1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
            1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
            1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
            0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0,
            0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0,
            0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1,
            0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1,
            1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0
        ][0:128]
        self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "TX")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "RX")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                          self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Demod")
        self.top_layout.addWidget(self.tab)
        self._range_noise_range = Range(0, 0.1, 0.005, 0, 200)
        self._range_noise_win = RangeWidget(self._range_noise_range,
                                            self.set_range_noise, "noise",
                                            "counter_slider", float)
        self.top_layout.addWidget(self._range_noise_win)
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_formatter = None
        else:
            self._variable_qtgui_label_0_formatter = lambda x: x

        self._variable_qtgui_label_0_tool_bar.addWidget(
            Qt.QLabel("RF Frequency" + ": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_formatter(
                    self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar,
                                       0, 1, 1, 1)

        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self._range_tx_gain_range = Range(0, 15, 1, 0, 200)
        self._range_tx_gain_win = RangeWidget(self._range_tx_gain_range,
                                              self.set_range_tx_gain,
                                              "Tx Gain", "counter_slider",
                                              float)
        self.top_grid_layout.addWidget(self._range_tx_gain_win, 1, 1, 1, 1)
        self._range_rx_gain_range = Range(0, 60, 1, 10, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range,
                                              self.set_range_rx_gain,
                                              "Rx Gain", "counter_slider",
                                              float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1, 0, 1, 1)
        self._range_mu_range = Range(0, 1, 0.01, 0.4, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range,
                                         self.set_range_mu,
                                         "BB Derotation Gain",
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2, 0, 1, 1)
        self._range_freq_range = Range(2.4e9, 4e9, 100e6, 3.0e9, 200)
        self._range_freq_win = RangeWidget(self._range_freq_range,
                                           self.set_range_freq, "IF Frequency",
                                           "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_freq_win, 0, 0, 1, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            256,  #size
            1,  #samp_rate
            "Frequency Offset",  #name
            1  #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(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 1, 0,
                                                    0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0_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 = [0, -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_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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            100000,  #size
            samp_rate,  #samp_rate
            "Correlation",  #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, 200)

        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_NORM,
                                                  qtgui.TRIG_SLOPE_POS, 20, 0,
                                                  1, "")
        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_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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            128,  #size
            "Payload",  #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_TAG,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "fd")
        self.qtgui_const_sink_x_0_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0_0.enable_grid(True)

        if not True:
            self.qtgui_const_sink_x_0_0.disable_legend()

        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 xrange(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.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.inets_rssi_0 = inets.rssi(0.000001)
        self.inets_radio_0 = inets_radio(
            constellation=qpsk_mod,
            matched_filter_coeff=rrc,
            mu=mu,
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            threshold=threshold,
        )
        self.inets_per_logger_0 = inets.per_logger()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost",
                                                     "52001", 10000, False)
        self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (range_noise, ))
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 1, 0, 1024)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.inets_radio_0, 'in'))
        self.msg_connect((self.inets_radio_0, 'out'),
                         (self.inets_per_logger_0, 'payload_in'))
        self.msg_connect((self.inets_radio_0, 'snr'),
                         (self.inets_per_logger_0, 'snr_in'))
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.inets_radio_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.inets_rssi_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.inets_radio_0, 2),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.inets_radio_0, 1),
                     (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.inets_radio_0, 5), (self.blocks_null_sink_0, 0))
        self.connect((self.inets_radio_0, 6), (self.blocks_null_sink_0_0, 0))
        self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.inets_radio_0, 4), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_add_xx_0, 0))
コード例 #38
0
    def __init__(self):
        gr.top_block.__init__(self, "Fm Channels")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fm Channels")
        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", "fm_channels")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.delta_f = delta_f = 75e3
        self.chan_rate = chan_rate = 192e3
        self.tx_ch_2 = tx_ch_2 = 3
        self.tx_ch_1 = tx_ch_1 = 1
        self.tx_ch_0 = tx_ch_0 = 0
        self.tx_amp_2 = tx_amp_2 = 1
        self.tx_amp_1 = tx_amp_1 = 1
        self.tx_amp_0 = tx_amp_0 = 1
        self.sensitivity = sensitivity = 2 * math.pi * delta_f / chan_rate
        self.rx_vol = rx_vol = 0.75
        self.rx_chan = rx_chan = 0
        self.nchans = nchans = 21
        self.audio_rate = audio_rate = 32e3

        ##################################################
        # Blocks
        ##################################################
        self._tx_ch_2_tool_bar = Qt.QToolBar(self)
        self._tx_ch_2_tool_bar.addWidget(Qt.QLabel('TX Channel 2' + ": "))
        self._tx_ch_2_line_edit = Qt.QLineEdit(str(self.tx_ch_2))
        self._tx_ch_2_tool_bar.addWidget(self._tx_ch_2_line_edit)
        self._tx_ch_2_line_edit.returnPressed.connect(lambda: self.set_tx_ch_2(
            int(str(self._tx_ch_2_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._tx_ch_2_tool_bar, 0, 3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_ch_1_tool_bar = Qt.QToolBar(self)
        self._tx_ch_1_tool_bar.addWidget(Qt.QLabel('TX Channel 1' + ": "))
        self._tx_ch_1_line_edit = Qt.QLineEdit(str(self.tx_ch_1))
        self._tx_ch_1_tool_bar.addWidget(self._tx_ch_1_line_edit)
        self._tx_ch_1_line_edit.returnPressed.connect(lambda: self.set_tx_ch_1(
            int(str(self._tx_ch_1_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._tx_ch_1_tool_bar, 0, 2, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_ch_0_tool_bar = Qt.QToolBar(self)
        self._tx_ch_0_tool_bar.addWidget(Qt.QLabel('TX Channel 0' + ": "))
        self._tx_ch_0_line_edit = Qt.QLineEdit(str(self.tx_ch_0))
        self._tx_ch_0_tool_bar.addWidget(self._tx_ch_0_line_edit)
        self._tx_ch_0_line_edit.returnPressed.connect(lambda: self.set_tx_ch_0(
            int(str(self._tx_ch_0_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._tx_ch_0_tool_bar, 0, 1, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_amp_2_range = Range(0, 1, 0.01, 1, 200)
        self._tx_amp_2_win = RangeWidget(self._tx_amp_2_range,
                                         self.set_tx_amp_2, 'TX Amp 2',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_amp_2_win, 1, 3, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_amp_1_range = Range(0, 1, 0.01, 1, 200)
        self._tx_amp_1_win = RangeWidget(self._tx_amp_1_range,
                                         self.set_tx_amp_1, 'TX Amp 1',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_amp_1_win, 1, 2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._tx_amp_0_range = Range(0, 1, 0.01, 1, 200)
        self._tx_amp_0_win = RangeWidget(self._tx_amp_0_range,
                                         self.set_tx_amp_0, 'TX Amp 0',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._tx_amp_0_win, 1, 1, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_vol_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_vol_win = RangeWidget(self._rx_vol_range, self.set_rx_vol,
                                       'RX Volume', "counter_slider", float)
        self.top_grid_layout.addWidget(self._rx_vol_win, 1, 0, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rx_chan_tool_bar = Qt.QToolBar(self)
        self._rx_chan_tool_bar.addWidget(Qt.QLabel('RX Channel' + ": "))
        self._rx_chan_line_edit = Qt.QLineEdit(str(self.rx_chan))
        self._rx_chan_tool_bar.addWidget(self._rx_chan_line_edit)
        self._rx_chan_line_edit.returnPressed.connect(lambda: self.set_rx_chan(
            int(str(self._rx_chan_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_chan_tool_bar, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            nchans * chan_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.01)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        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(-70, 0)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 2,
                                       2, 1, 2)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            nchans * chan_rate,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0.set_y_axis(-70, 0)
        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(0.2)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "magenta", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 0.5, 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_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, 2, 0, 1,
                                       2)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pfb_synthesizer_ccf_0 = filter.pfb_synthesizer_ccf(
            nchans,
            (firdes.low_pass_2(nchans, nchans * chan_rate, 100e3, 20e3, 50)),
            False)
        self.pfb_synthesizer_ccf_0.set_channel_map(
            ([tx_ch_0, tx_ch_1, tx_ch_2]))
        self.pfb_synthesizer_ccf_0.declare_sample_delay(0)

        self.pfb_decimator_ccf_0 = pfb.decimator_ccf(
            nchans, (firdes.low_pass_2(rx_vol, nchans * chan_rate,
                                       chan_rate / 2, chan_rate / 4, 50)),
            rx_chan, 100, True, True)
        self.pfb_decimator_ccf_0.declare_sample_delay(0)

        self.fft_filter_xxx_0 = filter.fft_filter_ccc(
            1, (firdes.complex_band_pass_2(
                1, nchans * chan_rate, (rx_chan * chan_rate) - chan_rate / 2,
                (rx_chan * chan_rate) + chan_rate / 2, chan_rate / 10, 80)), 1)
        self.fft_filter_xxx_0.declare_sample_delay(0)
        self.broadcast_fm_tx_0_0_0 = broadcast_fm_tx(
            audio_rate=audio_rate,
            chan_rate=chan_rate,
            sensitivity=sensitivity,
        )
        self.broadcast_fm_tx_0_0 = broadcast_fm_tx(
            audio_rate=audio_rate,
            chan_rate=chan_rate,
            sensitivity=sensitivity,
        )
        self.broadcast_fm_tx_0 = broadcast_fm_tx(
            audio_rate=audio_rate,
            chan_rate=chan_rate,
            sensitivity=sensitivity,
        )
        self.broadcast_fm_rx_0 = broadcast_fm_rx(
            audio_rate=audio_rate,
            bw=10e3,
            chan_rate=chan_rate,
            sensitivity=sensitivity,
        )
        self.blocks_wavfile_source_0_1 = blocks.wavfile_source(
            '/home/prabhat/Downloads/Untitled folder/PIERS project/fm tx rx/Martin Garrix - Animals.wav',
            True)
        self.blocks_wavfile_source_0_0 = blocks.wavfile_source(
            '/home/prabhat/Downloads/Untitled folder/PIERS project/fm tx rx/Charlie Puth (Feat. Selena Gomez) - We Don_t Talk Anymore.wav',
            True)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/home/prabhat/Downloads/Untitled folder/PIERS project/fm tx rx/Charlie Puth - Attention Official Video (1).wav',
            True)
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc(
            (tx_amp_2, ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc(
            (tx_amp_1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (tx_amp_0, ))
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.audio_sink_0 = audio.sink(int(audio_rate), 'pulse', True)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 0.1, 0, 8192)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.fft_filter_xxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.pfb_decimator_ccf_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_waterfall_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.pfb_synthesizer_ccf_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.pfb_synthesizer_ccf_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_1, 0),
                     (self.pfb_synthesizer_ccf_0, 2))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.broadcast_fm_tx_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.broadcast_fm_tx_0, 1))
        self.connect((self.blocks_wavfile_source_0_0, 0),
                     (self.broadcast_fm_tx_0_0, 0))
        self.connect((self.blocks_wavfile_source_0_0, 1),
                     (self.broadcast_fm_tx_0_0, 1))
        self.connect((self.blocks_wavfile_source_0_1, 0),
                     (self.broadcast_fm_tx_0_0_0, 0))
        self.connect((self.blocks_wavfile_source_0_1, 1),
                     (self.broadcast_fm_tx_0_0_0, 1))
        self.connect((self.broadcast_fm_rx_0, 1), (self.audio_sink_0, 1))
        self.connect((self.broadcast_fm_rx_0, 0), (self.audio_sink_0, 0))
        self.connect((self.broadcast_fm_tx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.broadcast_fm_tx_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.broadcast_fm_tx_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_1, 0))
        self.connect((self.fft_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.pfb_decimator_ccf_0, 0),
                     (self.broadcast_fm_rx_0, 0))
        self.connect((self.pfb_synthesizer_ccf_0, 0),
                     (self.blocks_add_xx_0, 0))
コード例 #39
0
ファイル: stream_usrp.py プロジェクト: psalmela/peregrine
  def __init__(self, filenames, dev_addrs, dual,
         onebit, iq, noise, mix, gain, fs, fc, unint, sync_pps):
    gr.top_block.__init__(self)
    if mix:
      raise NotImplementedError("TODO: Hilbert remix mode not implemented.")

    if dual:
      channels = [0, 1]
    else:
      channels = [0]
    uhd_sinks = [
      uhd.usrp_sink(",".join(
        [addr, "send_frame_size=32768,num_send_frames=128"]),
              uhd.stream_args(
                cpu_format="fc32",
                otwformat="sc8",
                channels=channels))
      for addr in dev_addrs]

    for sink in uhd_sinks:
      a = sink.get_usrp_info()
      for each in a.keys():
        print each + " : " + a.get(each)
      sink.set_clock_rate(fs, uhd.ALL_MBOARDS)
      sink.set_samp_rate(fs)
      sink.set_center_freq(fc, 0)
      sink.set_gain(gain, 0)
      if dual:
        sink.set_center_freq(fc, 1)
        sink.set_gain(gain, 1)
        sink.set_subdev_spec("A:B A:A", 0)
        # TODO Use offset tuning?
      if sync_pps:
        sink.set_clock_source("external") # 10 MHz
        sink.set_time_source("external") # PPS

    if unint:
      if noise or onebit or not iq:
        raise NotImplementedError("TODO: RX channel-interleaved mode only "
                      "supported for noiseless 8-bit complex.")

      BLOCK_N = 16*1024*1024
      demux = blocks.vector_to_streams(2, len(uhd_sinks))
      self.connect(blocks.file_source(2*len(uhd_sinks)*BLOCK_N, filenames[0], False),
             blocks.vector_to_stream(2*len(uhd_sinks), BLOCK_N),
             demux)
      for ix, sink in enumerate(uhd_sinks):
        self.connect((demux, ix),
               blocks.vector_to_stream(1, 2),
               blocks.interleaved_char_to_complex(), # [-128.0, +127.0]
               blocks.multiply_const_cc(1.0/1024), # [-0.125, 0.125)
#               blocks.vector_to_stream(8, 16*1024),
               sink)

    else:
      for i, filename in enumerate(filenames):
        src = blocks.file_source(gr.sizeof_char*1, filename, False)
        if dual:
          channel = i % 2
          sink = uhd_sinks[i/2]
        else:
          channel = 0
          sink = uhd_sinks[i]
        if iq:
          node = blocks.multiply_const_cc(1.0/1024)
          if onebit:
            self.connect(src,
                   blocks.unpack_k_bits_bb(8),
                   blocks.char_to_short(), # [0, 1] -> [0, 256]
                   blocks.add_const_ss(-128), # [-128, +128],
                   blocks.interleaved_short_to_complex(), # [ -128.0, +128.0]
                   node) # [-0.125, +0.125]
          else:
            self.connect(src, # [-128..127]
                   blocks.interleaved_char_to_complex(), # [-128.0, +127.0]
                   node) # [-0.125, +0.125)

        else:
          node = blocks.float_to_complex(1)
          if onebit:
            self.connect(src,
                   blocks.unpack_k_bits_bb(8), # [0, 1] -> [-0.125, +0.125]
                   blocks.char_to_float(vlen=1, scale=4),
                   blocks.add_const_vff((-0.125, )),
                   node)
          else:
            self.connect(src, # [-128..127] -> [-0.125, +0.125)
                   blocks.char_to_float(vlen=1, scale=1024),
                   node)

        if noise:
          combiner = blocks.add_vcc(1)
          self.connect((node, 0),
                 (combiner, 0),
                 (sink, channel))
          self.connect(analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise, -222, 8192),
                 (combiner, 1))
        else:
          self.connect((node, 0),
                 (sink, channel))

    print "Setting clocks..."
    if sync_pps:
      time.sleep(1.1) # Ensure there's been an edge.  TODO: necessary?
      last_pps_time = uhd_sinks[0].get_time_last_pps()
      while last_pps_time == uhd_sinks[0].get_time_last_pps():
        time.sleep(0.1)
      print "Got edge"
      [sink.set_time_next_pps(uhd.time_spec(round(time.time())+1)) for sink in uhd_sinks]
      time.sleep(1.0) # Wait for edge to set the clocks
    else:
      # No external PPS/10 MHz.  Just set each clock and accept some skew.
      t = time.time()
      [sink.set_time_now(uhd.time_spec(time.time())) for sink in uhd_sinks]
      if len(uhd_sinks) > 1:
        print "Uncabled; loosely synced only. Initial skew ~ %.1f ms" % (
          (time.time()-t) * 1000)

    t_start = uhd.time_spec(time.time() + 1.5)
    [sink.set_start_time(t_start) for sink in uhd_sinks]
    print "ready"
コード例 #40
0
	def sim ( self, arity, snr_db, N ):
		M = 1024
		theta_sel = 0
		syms_per_frame = 10
		zero_pads = 1
		center_preamble = [1, -1j, -1, 1j] # assumed to be normalized to 1
		qam_size = 2**arity
		preamble = [0]*M*zero_pads+center_preamble*((int)(M/len(center_preamble)))+[0]*M*zero_pads
		# num_symbols = 2**12
		exclude_preamble = 0
		exclude_multipath =0
		sel_taps = 0 # epa=0, eva = 1, etu=3
		freq_offset=0
		exclude_noise = 0
		sel_noise_type =0 # gaussian
		eq_select = 3
		# SNR = 20
		K = 4
		N = int( N ) # num of !samples!
		num_bits = N*arity
		# amp = math.sqrt(M/(10**(float(snr_db)/10)))/math.sqrt(2)
		# amp = math.sqrt((10**(float(-1*snr_db)/20))*(2*K*M+(2*syms_per_frame-1)*M)/(4*syms_per_frame))/math.sqrt(2)
		if exclude_preamble:
			amp = math.sqrt((10**(float(-1*snr_db)/10))*(2*K*M+(2*syms_per_frame-1)*M)/(4*syms_per_frame))/math.sqrt(2)
		else:
			amp = math.sqrt((10**(float(-1*snr_db)/10))*(M*(syms_per_frame+1)/(syms_per_frame+1+2*zero_pads))*((K*M+(2*syms_per_frame-1)*M/2)/(M*syms_per_frame)))/math.sqrt(2)
		# print amp
		# print amp2
		tx = transmitter_hier_bc(M, K, qam_size, syms_per_frame, theta_sel, exclude_preamble, center_preamble,1)
		rx = receiver_hier_cb(M, K, qam_size, syms_per_frame, theta_sel, eq_select, exclude_preamble, center_preamble,1)
		ch = channel_hier_cc(M, K, syms_per_frame, exclude_multipath, sel_taps, freq_offset, exclude_noise, sel_noise_type, snr_db, exclude_preamble, zero_pads)

		# # src = blocks.vector_source_b(src_data, vlen=1)
		xor_block = blocks.xor_bb()
		head1 = blocks.head(gr.sizeof_char*1, N)
		head0 = blocks.head(gr.sizeof_char*1, N)
		add_block = blocks.add_vcc(1)
		src = blocks.vector_source_b(map(int, numpy.random.randint(0, qam_size, 100000)), True)
		noise = analog.fastnoise_source_c(analog.GR_GAUSSIAN, amp, 0, 8192)
		dst = blocks.vector_sink_b(vlen=1)

		tb = gr.top_block ( "test_block" )
		tb.connect((src, 0), (head1, 0)) #esas
		tb.connect((head1, 0), (xor_block, 0)) #esas
		tb.connect((src, 0), (tx, 0)) #esas
		tb.connect((tx, 0), (add_block, 0)) #esas
		tb.connect((noise, 0), (add_block, 1)) #esas
		# tb.connect((head0, 0), (add_block, 1)) #esas
		tb.connect((add_block, 0), (rx, 0)) #esas
		tb.connect((rx, 0),(head0, 0)) #esas
		tb.connect((head0, 0), (xor_block, 1)) #esas
		tb.connect((xor_block, 0), (dst, 0)) #esas  

		tb.run()

		# what we record in dst.data will be output of xor_block. now we have to process those data
		# so as to find bit errors.
		result_data = dst.data()

		bit_errors = 0
		for i in range(len(result_data)):
			# print bin(result_data[i])
			bit_errors = bit_errors + (bin(result_data[i]).count('1'))

		# print len(result_data)

		# return 1

		return float(bit_errors) / num_bits
コード例 #41
0
    def __init__(self, options):
        gr.top_block.__init__(self, "ofdm_benchmark")

        self._bandwidth = options.bandwidth
        self.servants = []
        self._verbose = options.verbose

        self._options = copy.copy(options)

        self.ideal = options.ideal
        self.ideal2 = options.ideal2

        rms_amp = options.rms_amplitude

        self._interpolation = 1

        f1 = numpy.array([
            -107, 0, 445, 0, -1271, 0, 2959, 0, -6107, 0, 11953, 0, -24706, 0,
            82359, 262144 / 2, 82359, 0, -24706, 0, 11953, 0, -6107, 0, 2959,
            0, -1271, 0, 445, 0, -107
        ], numpy.float64) / 262144.

        print "Software interpolation: %d" % (self._interpolation)

        bw = 1.0 / self._interpolation
        tb = bw / 5
        if self._interpolation > 1:
            self.tx_filter = gr.hier_block2(
                "filter", gr.io_signature(1, 1, gr.sizeof_gr_complex),
                gr.io_signature(1, 1, gr.sizeof_gr_complex))
            self.tx_filter.connect(self.tx_filter,
                                   gr.interp_fir_filter_ccf(2, f1),
                                   gr.interp_fir_filter_ccf(2, f1),
                                   self.tx_filter)

            print "New"

        else:
            self.tx_filter = None

        self.decimation = 1

        if self.decimation > 1:
            bw = 0.5 / self.decimation * 1
            tb = bw / 5
            # gain, sampling rate, passband cutoff, stopband cutoff
            # passband ripple in dB, stopband attenuation in dB
            # extra taps
            filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw + tb, 0.1, 60.0, 1)
            print "Software decimation filter length: %d" % (len(filt_coeff))
            self.rx_filter = gr.fir_filter_ccf(self.decimation, filt_coeff)
        else:
            self.rx_filter = None

        self._setup_tx_path(options)
        self._setup_rx_path(options)
        self._setup_rpc_manager()

        config = self.config = station_configuration()

        if options.imgxfer:
            self.rxpath.setup_imgtransfer_sink()

        if not options.no_decoding:
            self.rxpath.publish_rx_performance_measure()

            # capture transmitter's stream to disk
        #self.dst  = gr.file_sink(gr.sizeof_gr_complex,options.to_file)
        self.dst = self.rxpath
        if options.force_rx_filter:
            print "Forcing rx filter usage"
            self.connect(self.rx_filter, self.dst)
            self.dst = self.rx_filter

        if options.ideal or self.ideal2:
            self._amplifier = ofdm.multiply_const_ccf(1.0)
            self.connect(self._amplifier, self.dst)
            self.dst = self._amplifier
            self.set_rms_amplitude(rms_amp)

        if options.measure:
            self.m = throughput_measure(gr.sizeof_gr_complex)
            self.connect(self.m, self.dst)
            self.dst = self.m

        if options.snr is not None:
            if options.berm is not None:
                noise_sigma = 380 / 32767.0  #empirically given, gives the received SNR range of (1:28) for tx amp. range of (500:10000) which is set in rm_ber_measurement.py
                #check for fading channel
            else:
                snr_db = options.snr
                snr = 10.0**(snr_db / 10.0)
                noise_sigma = sqrt(config.rms_amplitude**2 / snr)

            print " Noise St. Dev. %f" % (noise_sigma)

            awgn_chan = blocks.add_cc()
            #awgn_noise_src = ofdm.complex_white_noise( 0.0, noise_sigma )
            awgn_noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN,
                                                       noise_sigma, 0, 8192)
            self.connect(awgn_noise_src, (awgn_chan, 1))
            self.connect(awgn_chan, self.dst)
            self.dst = awgn_chan

        if options.freqoff is not None:
            freq_off = self.freq_off = channel.freq_offset(options.freqoff)
            dst = self.dst
            self.connect(freq_off, dst)
            self.dst = freq_off
            self.rpc_mgr_tx.add_interface("set_freq_offset",
                                          self.freq_off.set_freqoff)

        if options.multipath:
            if options.itu_channel:
                self.fad_chan = channel.itpp_channel(options.bandwidth)
                self.rpc_mgr_tx.add_interface(
                    "set_channel_profile", self.fad_chan.set_channel_profile)
                self.rpc_mgr_tx.add_interface("set_norm_doppler",
                                              self.fad_chan.set_norm_doppler)
            else:
                #self.fad_chan = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j])
                # filter coefficients for the lab exercise
                self.fad_chan = filter.fir_filter_ccc(1,
                                                      [0.3267, 0.8868, 0.3267])
                #self.fad_chan = filter.fir_filter_ccc(1,[0,0,0.1,0.2,0.01,0.3])#0.3267,0.8868,0.3267])
                #self.fad_chan = channels.selective_fading_model(5, 0.1, False, 1, -1, [0, 0, 0], [0.3267,0.8868,0.3267], 10 )
                #self.fad_chan = channels.fading_model(6, 0.05, False);
                #self.fad_chan = channels.dynamic_channel_model(1000000, 0, 0, 0, 0, 3, 0.01, False, 0, [2e-6,4e-6,8e-6],[0.3267,0.8868,0.3267], 20, 0, 0)

            self.connect(self.fad_chan, self.dst)
            self.dst = self.fad_chan

        if options.samplingoffset is not None:
            soff = options.samplingoffset
            interp = moms(1000000 * (1.0 + soff), 1000000)
            #interp = filter.fractional_resampler_cc(0,1000000*(1.0+soff)/1000000.0)
            self.connect(interp, self.dst)
            self.dst = interp

            if options.record:
                log_to_file(self, interp, "data/interp_out.compl")

        tmm = blocks.throttle(gr.sizeof_gr_complex, options.bandwidth)
        self.connect(tmm, self.dst)
        self.dst = tmm
        if options.force_tx_filter:
            print "Forcing tx filter usage"
            self.connect(self.tx_filter, self.dst)
            self.dst = self.tx_filter
        if options.record:
            log_to_file(self, self.txpath, "data/txpath_out.compl")

        if options.scatterplot:
            print "Scatterplot enabled"

        self.connect(self.txpath, self.dst)

        print "Hit Strg^C to terminate"

        print "Hit Strg^C to terminate"

        # Display some information about the setup
        if self._verbose:
            self._print_verbage()
コード例 #42
0
  def __init__ (self, options):
    gr.top_block.__init__(self, "ofdm_mrrc_benchmark")

    ##self._tx_freq            = options.tx_freq         # tranmitter's center frequency
    ##self._tx_subdev_spec     = options.tx_subdev_spec  # daughterboard to use
    ##self._fusb_block_size    = options.fusb_block_size # usb info for USRP
    ##self._fusb_nblocks       = options.fusb_nblocks    # usb info for USRP
    ##self._which              = options.which_usrp
    self._bandwidth          = options.bandwidth
    self.servants = []
    self._verbose            = options.verbose
    
    ##self._interface          = options.interface
    ##self._mac_addr           = options.mac_addr

    self._options = copy.copy( options )


    self._interpolation = 1
    
    f1 = numpy.array([-107,0,445,0,-1271,0,2959,0,-6107,0,11953,
                      0,-24706,0,82359,262144/2,82359,0,-24706,0,
                      11953,0,-6107,0,2959,0,-1271,0,445,0,-107],
                      numpy.float64)/262144.
    
    print "Software interpolation: %d" % (self._interpolation)

    bw = 1.0/self._interpolation
    tb = bw/5
    if self._interpolation > 1:
      self.tx_filter = gr.hier_block2("filter",
                                   gr.io_signature(1,1,gr.sizeof_gr_complex),
                                   gr.io_signature(1,1,gr.sizeof_gr_complex))
      self.tx_filter2 = gr.hier_block2("filter",
                                   gr.io_signature(1,1,gr.sizeof_gr_complex),
                                   gr.io_signature(1,1,gr.sizeof_gr_complex))
      self.tx_filter.connect( self.tx_filter, gr.interp_fir_filter_ccf(2,f1),
                           gr.interp_fir_filter_ccf(2,f1), self.tx_filter )
      self.tx_filter2.connect( self.tx_filter2, gr.interp_fir_filter_ccf(2,f1),
                           gr.interp_fir_filter_ccf(2,f1), self.tx_filter2 )
      print "New"

    else:
      self.tx_filter = None
      self.tx_filter2 = None
      
    self.decimation = 1
    
    if self.decimation > 1:
      bw = 0.5/self.decimation * 1
      tb = bw/5
      # gain, sampling rate, passband cutoff, stopband cutoff
      # passband ripple in dB, stopband attenuation in dB
      # extra taps
      filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw+tb, 0.1, 60.0, 1)
      print "Software decimation filter length: %d" % (len(filt_coeff))
      self.rx_filter = gr.fir_filter_ccf(self.decimation,filt_coeff)
      self.rx_filter2 = gr.fir_filter_ccf(self.decimation,filt_coeff)
    else:
      self.rx_filter = None
      self.rx_filter2 = None
      
      
##    if not options.from_file is None:
##      # sent captured file to usrp
##      self.src = gr.file_source(gr.sizeof_gr_complex,options.from_file)
##      self._setup_usrp_sink()
##      if hasattr(self, "filter"):
##        self.connect(self.src,self.filter,self.u) #,self.filter
##      else:
##        self.connect(self.src,self.u)
##      
##      return 
    
    
    
    self._setup_tx_path(options)
    self._setup_rx_path(options)
    self._setup_rpc_manager()
    
    config = self.config = station_configuration()
    
    #self.enable_txfreq_adjust("txfreq")
    
    

    if options.imgxfer:
      self.rxpath.setup_imgtransfer_sink()
    
    if not options.no_decoding:
      self.rxpath.publish_rx_performance_measure()
      
    


    self.dst	= (self.rxpath,0)
    self.dst2 	= (self.rxpath,1)
    
    if options.force_rx_filter:
      print "Forcing rx filter usage"
      self.connect( self.rx_filter, self.dst )
      self.connect( self.rx_filter2, self.dst2 )
      self.dst = self.rx_filter
      self.dst2 = self.rx_filter2
    
    
    if options.measure:
      self.m = throughput_measure(gr.sizeof_gr_complex)
      self.m2 = throughput_measure(gr.sizeof_gr_complex)
      self.connect( self.m, self.dst )
      self.connect( self.m2, self.dst2 )
      self.dst = self.m
      self.dst2 = self.m2


    if options.snr is not None:
      if options.berm is not None:
          noise_sigma = 380/32767.0 #empirically given, gives the received SNR range of (1:28) for tx amp. range of (500:10000) which is set in rm_ber_measurement.py
          print " Noise St. Dev. %f" % (noise_sigma)#check for fading channel 
      else:
          snr_db = options.snr
          snr = 10.0**(snr_db/10.0)
          noise_sigma = sqrt( config.rms_amplitude**2 / snr )
          
      print " Noise St. Dev. %f" % (noise_sigma)
      awgn_chan = blocks.add_cc()
      awgn_chan2 = blocks.add_cc()
      awgn_noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma, 0, 8192)
      awgn_noise_src2 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma*2, 0, 2192)
      self.connect( awgn_chan, self.dst )
      self.connect( awgn_chan2, self.dst2 )
      self.connect( awgn_noise_src, (awgn_chan,1) )
      self.connect( awgn_noise_src2, (awgn_chan2,1) )  
      self.dst = awgn_chan
      self.dst2 = awgn_chan2



    if options.freqoff is not None:
      freq_off = self.freq_off = channel.freq_offset(options.freqoff )
      freq_off2 = self.freq_off2  = channel.freq_offset(options.freqoff )
      dst = self.dst
      dst2 = self.dst2
      self.connect( freq_off, dst )
      self.connect( freq_off2, dst2 )
      self.dst = freq_off
      self.dst2 = freq_off2
      self.rpc_mgr_tx.add_interface("set_freq_offset",self.freq_off.set_freqoff)
      self.rpc_mgr_tx.add_interface("set_freq_offset2",self.freq_off2.set_freqoff)


    if options.multipath:
      if options.itu_channel:
        self.fad_chan = channel.itpp_channel(options.bandwidth)
          #fad_chan.set_norm_doppler( 1e-9 )
          #fad_chan.set_LOS( [500.,0,0] )
        self.fad_chan2 = channel.itpp_channel(options.bandwidth)
        self.fad_chan.set_channel_profile( itpp.ITU_Pedestrian_A, 5e-8 )
        self.fad_chan.set_norm_doppler( 1e-8 )
        self.fad_chan2.set_channel_profile( itpp.ITU_Pedestrian_A, 5e-8 )
        self.fad_chan2.set_norm_doppler( 1e-8 )
        self.rpc_mgr_tx.add_interface("set_channel_profile",self.fad_chan.set_channel_profile)
        self.rpc_mgr_tx.add_interface("set_channel_profile",self.fad_chan2.set_channel_profile)
      else:
        fad_chan = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j])
        fad_chan2 = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j])
        
      self.connect( self.fad_chan, self.dst )
      self.connect( self.fad_chan2, self.dst2 )
      self.dst = self.fad_chan
      self.dst2 = self.fad_chan2

    if options.samplingoffset is not None:
      soff = options.samplingoffset
      interp = moms(1000000*(1.0+soff),1000000)
      interp2 = moms(1000000*(1.0+soff),1000000)
      self.connect( interp, self.dst )
      self.connect( interp2, self.dst2 )
      self.dst = interp
      self.dst2 = interp2
      
      if options.record:
       log_to_file( self, interp, "data/interp_out.compl" )
       log_to_file( self, interp2, "data/interp2_out.compl" )
    
    tmm =blocks.throttle(gr.sizeof_gr_complex, 1e6)
    #tmm2 =blocks.throttle(gr.sizeof_gr_complex, 1e6)
    
    #self.connect( tmm, self.dst )
    #self.connect( tmm2, self.dst2 )
    #self.dst = tmm
    #self.dst2 = tmm2
    
    #inter = blocks.interleave(gr.sizeof_gr_complex)
    #deinter = blocks.deinterleave(gr.sizeof_gr_complex)
    
    # Interleaving input/output streams
    ##self.connect(inter, deinter)
    #self.connect((deinter,0),self.dst)
    #self.connect((deinter,1),self.dst2)
    #self.dst = inter
    #self.dst2 = (inter,1)
    
    
    if options.force_tx_filter:
      print "Forcing tx filter usage"
      self.connect( self.tx_filter, self.dst )
      self.connect( self.tx_filter2, self.dst2 )
      self.dst = self.tx_filter
      self.dst2 = self.tx_filter2
    if options.record:
      log_to_file( self, self.txpath, "data/txpath_out.compl" )
      log_to_file( self, self.txpath2, "data/txpath2_out.compl" )
      
    if options.nullsink:
        self.connect(gr.null_source(gr.sizeof_gr_complex), self.dst)
        self.connect(gr.null_source(gr.sizeof_gr_complex), self.dst2)
        self.dst = gr.null_sink(gr.sizeof_gr_complex)
        self.dst2 = gr.null_sink(gr.sizeof_gr_complex)
        
    
    self.connect( self.txpath,tmm,self.dst )
    self.connect( tmm,self.dst2 )
    #self.connect( self.txpath,self.dst2 )
    
    print "Hit Strg^C to terminate"

    if self._verbose:
        self._print_verbage()
コード例 #43
0
ファイル: qa_fastnoise.py プロジェクト: danbar/gnuradio
 def test_003_cmplx_uniform_pool(self):
     src = analog.fastnoise_source_c(type=analog.GR_UNIFORM, **self.default_args)
     src2 = analog.fastnoise_source_c(type=analog.GR_UNIFORM, **self.default_args)
     self.assertTrue(numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples())))
コード例 #44
0
ファイル: mpsk_stage3.py プロジェクト: n-west/gr-west
    def __init__(self):
        gr.top_block.__init__(self, "Mpsk Stage3")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Mpsk Stage3")
        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", "mpsk_stage3")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 8
        self.payload = payload = range(256)
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 6.28/100.0
        self.taps = taps = [1.0 + 0.0j, ]
        self.samp_rate = samp_rate = 250e3
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts)
        self.qpsk_const = qpsk_const = digital.constellation_rect(([-1, +1]), ([0, 1]), 1, 2, 1, 1, 1).base()
        self.payload_str = payload_str = ''.join(map(lambda x: "{0:08b}".format(x), payload))
        self.gain = gain = 50
        self.freq = freq = 2.3e9
        self.excess_bw = excess_bw = 0.35
        self.delay = delay = 32
        self.decim = decim = 1
        self.arity = arity = 2
        self.access_code_str = access_code_str = "1111100110101"
        self.access_code = access_code = [31, 53]

        ##################################################
        # Blocks
        ##################################################
        self._delay_layout = Qt.QVBoxLayout()
        self._delay_tool_bar = Qt.QToolBar(self)
        self._delay_layout.addWidget(self._delay_tool_bar)
        self._delay_tool_bar.addWidget(Qt.QLabel("delay"+": "))
        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._delay_counter = qwt_counter_pyslot()
        self._delay_counter.setRange(0, 100, 1)
        self._delay_counter.setNumButtons(2)
        self._delay_counter.setValue(self.delay)
        self._delay_tool_bar.addWidget(self._delay_counter)
        self._delay_counter.valueChanged.connect(self.set_delay)
        self._delay_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._delay_slider.setRange(0, 100, 1)
        self._delay_slider.setValue(self.delay)
        self._delay_slider.setMinimumWidth(200)
        self._delay_slider.valueChanged.connect(self.set_delay)
        self._delay_layout.addWidget(self._delay_slider)
        self.top_layout.addLayout(self._delay_layout)
        self.west_stream_trigged_pdu_0 = west.stream_trigged_pdu("start_payload", 2048)
        self.west_ber_pdu_0 = west.ber_pdu(payload_str)
        self._timing_loop_bw_layout = Qt.QVBoxLayout()
        self._timing_loop_bw_label = Qt.QLabel("Time: BW")
        self._timing_loop_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._timing_loop_bw_slider.setRange(0.0, 0.2, 0.005)
        self._timing_loop_bw_slider.setValue(self.timing_loop_bw)
        self._timing_loop_bw_slider.setMinimumWidth(200)
        self._timing_loop_bw_slider.valueChanged.connect(self.set_timing_loop_bw)
        self._timing_loop_bw_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_label)
        self._timing_loop_bw_layout.addWidget(self._timing_loop_bw_slider)
        self.top_grid_layout.addLayout(self._timing_loop_bw_layout, 3,1,1,1)
        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, 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(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", "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.qtgui_const_sink_x_1_0 = qtgui.const_sink_c(
        	1024, #size
        	"Equalizer", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_1_0.set_update_time(0.10)
        self.qtgui_const_sink_x_1_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1_0.enable_autoscale(False)
        self.qtgui_const_sink_x_1_0.enable_grid(False)
        
        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 xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_1_0_win = sip.wrapinstance(self.qtgui_const_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_0_win)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
        	1024, #size
        	"Clock Sync Output", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        
        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 xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])
        
        self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	2048, #size
        	"Costas Loop Output", #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)
        
        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 xrange(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, 0,1,1,1)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  1,
                  taps=(rrc_taps[:-1]),
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        	
        self._gain_layout = Qt.QVBoxLayout()
        self._gain_tool_bar = Qt.QToolBar(self)
        self._gain_layout.addWidget(self._gain_tool_bar)
        self._gain_tool_bar.addWidget(Qt.QLabel("RF gain"+": "))
        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._gain_counter = qwt_counter_pyslot()
        self._gain_counter.setRange(0, 90, 1)
        self._gain_counter.setNumButtons(2)
        self._gain_counter.setValue(self.gain)
        self._gain_tool_bar.addWidget(self._gain_counter)
        self._gain_counter.valueChanged.connect(self.set_gain)
        self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._gain_slider.setRange(0, 90, 1)
        self._gain_slider.setValue(self.gain)
        self._gain_slider.setMinimumWidth(200)
        self._gain_slider.valueChanged.connect(self.set_gain)
        self._gain_layout.addWidget(self._gain_slider)
        self.top_layout.addLayout(self._gain_layout)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.015, 2)
        self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb(access_code_str, 1)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=qpsk_const,
          differential=True,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=excess_bw,
          verbose=False,
          log=False,
          )
        (self.digital_constellation_modulator_0).set_processor_affinity([2])
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(qpsk_const)
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(16, 1, 0.15/100., 1)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc(sps*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b([135, 201]*5000 + access_code + payload*100000, False, 1, [])
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.0001, ))
        self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_char*1, int(delay))
        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 = blocks.add_vcc(1)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 0.3, 0, 8192)
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-1, 1.0, 1)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_constellation_modulator_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_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_const_sink_x_1, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0), (self.qtgui_const_sink_x_1_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_correlate_access_code_bb_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_keep_one_in_n_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_correlate_access_code_bb_0, 0), (self.west_stream_trigged_pdu_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0))
        self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.west_stream_trigged_pdu_0, "pdus", self.west_ber_pdu_0, "pdus")
コード例 #45
0
    def __init__(self, eve_noise_db=1, channel_noise_db=1, max_items=8):
        gr.top_block.__init__(self, "Eve Re Learn Testbed Graph")

        ##################################################
        # Variables
        ##################################################
        self.snr_db = snr_db = 0
        self.samp_rate = samp_rate = 10000000
        self.max_items = max_items
        self.eve_noise_db = eve_noise_db
        self.channel_noise_db = channel_noise_db
        self.const = const = digital.constellation_calcdist(
            ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()

        ##################################################
        # Blocks
        ##################################################
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            const)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (const.points()), 1)
        self.blocks_vector_sink_alice = blocks.vector_sink_b(1)
        self.blocks_vector_sink_bob = blocks.vector_sink_b(1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb(
            1, 8, "", False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            1, const.bits_per_symbol(), "", False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            const.bits_per_symbol(), 8, "", False, gr.GR_LSB_FIRST)
        self.blocks_head_0_0 = blocks.head(gr.sizeof_char * 1, max_items)
        self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, max_items)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, np.random.randint(0, 2, 1000000)), True)
        self.analog_fastnoise_source_x_0_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 10**(self.eve_noise_db / 20.0), 0, 2**16)
        self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(
            analog.GR_GAUSSIAN, 10**(self.channel_noise_db / 20.0), 0, 2**16)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_fastnoise_source_x_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.analog_fastnoise_source_x_0_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_repack_bits_bb_1, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.blocks_head_0, 0), (self.blocks_vector_sink_bob, 0))
        self.connect((self.blocks_head_0_0, 0),
                     (self.blocks_vector_sink_alice, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_head_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_repack_bits_bb_1, 0),
                     (self.blocks_head_0_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
コード例 #46
0
ファイル: test_demapper.py プロジェクト: WindyCitySDR/gr-ofdm
  def sim ( self, arity, snr_db, N ):
    
    vlen = 10
    N = int( N )
    snr = 10.0**(snr_db/10.0)
    
    sigpow = 1.0
    noise_pow = sigpow / snr
    #skipping first symbol due to demapper implementation (demmaper assumes that the first symbol is ID and do not decode ui)
    skiphead_src = blocks.skiphead( gr.sizeof_char, vlen+3)#vlen+3 )
    demapper = ofdm.generic_demapper_vcb( vlen,N/vlen+1 )
    const = demapper.get_constellation( arity )
    assert( len( const ) == 2**arity )
    
    symsrc = ofdm.symbol_random_src( const, vlen )
    #noise_src = ofdm.complex_white_noise( 0.0, sqrt( noise_pow ) )
    noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, 0.0, 0, 8192)
    channel = blocks.add_cc()
    ch_model = channels.channel_model(
            noise_voltage=0.0,
            frequency_offset=0.0,
            epsilon=1.0,
            #taps = (0.998160541385960,0.0605566335500750,0.00290305927764350),
            taps = (1,0),
            noise_seed=8192,
            block_tags=False
        )
    bitmap_src = blocks.vector_source_b( [arity] * vlen, True, vlen )
    #bm_trig_src = blocks.vector_source_b( [1], True )
    ref_bitstream = blocks.unpack_k_bits_bb( arity )
    bitstream_xor = blocks.xor_bb()
    bitstream_c2f = blocks.char_to_float()
    acc_biterr = ofdm.accumulator_ff()
    skiphead = blocks.skiphead( gr.sizeof_float, N-1 )
    limit = blocks.head( gr.sizeof_float, 1 )
    dst = blocks.vector_sink_f()
    
    rec_dst = blocks.vector_sink_b()
    ref_dst = blocks.vector_sink_b()
    
    tb = gr.top_block ( "test_block" )
    #tb.connect( (symsrc,0),blocks.vector_to_stream(gr.sizeof_gr_complex ,vlen),blocks.head(gr.sizeof_gr_complex,N/arity),blocks.null_sink(gr.sizeof_gr_complex))
    
    #tb.connect( (symsrc,0),fft.fft_vcc(vlen,False,[],True),blocks.vector_to_stream(gr.sizeof_gr_complex ,vlen), ch_model, (channel,0) )
    tb.connect( (symsrc,0),blocks.vector_to_stream(gr.sizeof_gr_complex ,vlen), ch_model, (channel,0) )
    tb.connect( noise_src,  (channel,1) )
    #tb.connect( channel, blocks.stream_to_vector(gr.sizeof_gr_complex ,vlen),fft.fft_vcc(vlen,True,[],True),  (demapper,0), (bitstream_xor,0) )
    tb.connect( channel, blocks.stream_to_vector(gr.sizeof_gr_complex ,vlen), (demapper,0), (bitstream_xor,0) )
    tb.connect( bitmap_src,  (demapper,1) )
    #tb.connect( bm_trig_src, (demapper,2) )
    tb.connect( (symsrc,1),blocks.vector_to_stream(gr.sizeof_char ,vlen),skiphead_src, ref_bitstream, (bitstream_xor,1) )
    tb.connect( bitstream_xor, bitstream_c2f, acc_biterr )
    tb.connect( acc_biterr, skiphead, limit, dst )
    tb.connect( demapper, rec_dst )
    tb.connect( ref_bitstream,  ref_dst )

    tb.run()
    
    bit_errors = numpy.array( dst.data() )
    assert( len( bit_errors ) == 1 )
    bit_errors = bit_errors[0]
    
    rec_data = list(rec_dst.data())
    ref_data = list(ref_dst.data())
    
    print "ref_data: ", ref_data[:2000]
    print "size ref_data: ", len(ref_data)#[:2320
    print "rec_data: ", rec_data[:500]
    print "size rec_data: ", len(rec_data)#[:2320
    
    return bit_errors / N