コード例 #1
0
    def test_stretch_01(self):
        tb = self.tb

        data = 10*[1,]
        data0 = [x / 20.0 for x in data]
        data1 = [x / 10.0 for x in data]

        expected_result0 = 10*[0.05,]
        expected_result1 = 10*[0.1,]

        src0 = blocks.vector_source_f(data0, False)
        src1 = blocks.vector_source_f(data1, False)
        inter = blocks.streams_to_vector(gr.sizeof_float, 2)
        op = blocks.stretch_ff(0.1, 2)
        deinter = blocks.vector_to_streams(gr.sizeof_float, 2)
        dst0 = blocks.vector_sink_f()
        dst1 = blocks.vector_sink_f()

        tb.connect(src0, (inter,0))
        tb.connect(src1, (inter,1))
        tb.connect(inter, op)
        tb.connect(op, deinter)
        tb.connect((deinter,0), dst0)
        tb.connect((deinter,1), dst1)
        tb.run()

        dst0_data = dst0.data()
        dst1_data = dst1.data()

        self.assertFloatTuplesAlmostEqual(expected_result0, dst0_data, 4)
        self.assertFloatTuplesAlmostEqual(expected_result1, dst1_data, 4)
コード例 #2
0
    def test_vector_int(self):
        tb = self.tb

        vlen = 5
        N = 10 * vlen
        data = make_random_float_tuple(N, 2**10)
        data = [int(d * 1000) for d in data]
        src = blocks.vector_source_i(data, False)
        one_to_many = blocks.stream_to_streams(gr.sizeof_int, vlen)
        one_to_vector = blocks.stream_to_vector(gr.sizeof_int, vlen)
        many_to_vector = blocks.streams_to_vector(gr.sizeof_int, vlen)
        isolated = [blocks.moving_average_ii(100, 1) for i in range(vlen)]
        dut = blocks.moving_average_ii(100, 1, vlen=vlen)
        dut_dst = blocks.vector_sink_i(vlen=vlen)
        ref_dst = blocks.vector_sink_i(vlen=vlen)

        tb.connect(src, one_to_many)
        tb.connect(src, one_to_vector, dut, dut_dst)
        tb.connect(many_to_vector, ref_dst)
        for idx, single in enumerate(isolated):
            tb.connect((one_to_many, idx), single, (many_to_vector, idx))

        tb.run()

        dut_data = dut_dst.data()
        ref_data = ref_dst.data()

        # make sure result is close to zero
        self.assertTupleEqual(dut_data, ref_data)
コード例 #3
0
ファイル: qa_moving_average.py プロジェクト: danbar/gnuradio
    def test_03(self):
        tb = self.tb

        vlen = 5
        N = 10*vlen
        seed = 0
        data = make_random_float_tuple(N, 2**10)
        data = [int(d*1000) for d in data]
        src = blocks.vector_source_i(data, False)
        one_to_many = blocks.stream_to_streams(gr.sizeof_int, vlen)
        one_to_vector = blocks.stream_to_vector(gr.sizeof_int, vlen)
        many_to_vector = blocks.streams_to_vector(gr.sizeof_int, vlen)
        isolated  = [ blocks.moving_average_ii(100, 1) for i in range(vlen)]
        dut = blocks.moving_average_ii(100, 1, vlen=vlen)
        dut_dst = blocks.vector_sink_i(vlen=vlen)
        ref_dst = blocks.vector_sink_i(vlen=vlen)

        tb.connect(src, one_to_many)
        tb.connect(src, one_to_vector, dut, dut_dst)
        tb.connect(many_to_vector, ref_dst)
        for idx, single in enumerate(isolated):
            tb.connect((one_to_many,idx), single, (many_to_vector,idx))

        tb.run()

        dut_data = dut_dst.data()
        ref_data = ref_dst.data()

        # make sure result is close to zero
        self.assertTupleEqual(dut_data, ref_data)
コード例 #4
0
ファイル: qa_stretch.py プロジェクト: 232675/gnuradio
    def test_stretch_01(self):
        tb = self.tb

        data = 10*[1,]
        data0 = map(lambda x: x/20.0, data)
        data1 = map(lambda x: x/10.0, data)

        expected_result0 = 10*[0.05,]
        expected_result1 = 10*[0.1,]

        src0 = blocks.vector_source_f(data0, False)
        src1 = blocks.vector_source_f(data1, False)
        inter = blocks.streams_to_vector(gr.sizeof_float, 2)
        op = blocks.stretch_ff(0.1, 2)
        deinter = blocks.vector_to_streams(gr.sizeof_float, 2)
        dst0 = blocks.vector_sink_f()
        dst1 = blocks.vector_sink_f()
        
        tb.connect(src0, (inter,0))
        tb.connect(src1, (inter,1))
        tb.connect(inter, op)
        tb.connect(op, deinter)
        tb.connect((deinter,0), dst0)
        tb.connect((deinter,1), dst1)
        tb.run()

        dst0_data = dst0.data()
        dst1_data = dst1.data()

        self.assertFloatTuplesAlmostEqual(expected_result0, dst0_data, 4)
        self.assertFloatTuplesAlmostEqual(expected_result1, dst1_data, 4)
コード例 #5
0
    def __init__(self, filename, dev_addrs,
                 onebit, gain, digital_gain, fs, fc, sync_pps):
        gr.top_block.__init__(self)

        if onebit:
            raise NotImplementedError("TODO: 1-bit mode not implemented.")
        
        uhd_srcs = [
            uhd.usrp_source(",".join(
                [addr, "num_recv_frames=256,recv_frame_size=16384"]),
                          uhd.stream_args(
                              cpu_format="fc32",
                              otwformat="sc16",
                              channels=[0]))
            for addr in dev_addrs]

        str2vec = blocks.streams_to_vector(2, len(uhd_srcs))
        self.connect(str2vec,
                     blocks.stream_to_vector(2 * len(uhd_srcs), 16*1024*1024),
                     blocks.file_sink(2 * len(uhd_srcs) * 16 * 1024 * 1024, filename, False))
        
        for ix, src in enumerate(uhd_srcs):
            src.set_clock_rate(fs*2, uhd.ALL_MBOARDS)
            src.set_samp_rate(fs)
            src.set_center_freq(uhd.tune_request(fc, 3e6))
            src.set_gain(gain, 0)
            # TODO Use offset tuning?
            if sync_pps:
                src.set_clock_source("external") # 10 MHz
                src.set_time_source("external") # PPS

            self.connect(src,  # [-1.0, 1.0]
                         blocks.multiply_const_cc(32767 * digital_gain[ix]), # [-32767.0, 32767.0]
                         blocks.complex_to_interleaved_short(), #[-32768, 32767]
                         blocks.short_to_char(), #[-128, 127]
                         blocks.stream_to_vector(1, 2), # I,Q,I,Q -> IQ, IQ
                         (str2vec, ix))

        print "Setting clocks..."
        if sync_pps:
            time.sleep(1.1) # Ensure there's been an edge.  TODO: necessary?
            last_pps_time = uhd_srcs[0].get_time_last_pps()
            while last_pps_time == uhd_srcs[0].get_time_last_pps():
                time.sleep(0.1)
            print "Got edge"
            [src.set_time_next_pps(uhd.time_spec(round(time.time())+1)) for src in uhd_srcs]
            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()
            [src.set_time_now(uhd.time_spec(time.time())) for src in uhd_srcs]
            if len(uhd_srcs) > 1:
                print "Uncabled; loosely synced only. Initial skew ~ %.1f ms" % (
                    (time.time()-t) * 1000)

        t_start = uhd.time_spec(time.time() + 1.5)
        [src.set_start_time(t_start) for src in uhd_srcs]
        print "ready"
コード例 #6
0
 def connect_audio_output(self, l_endpoint, r_endpoint=None):
     stereo = r_endpoint is not None
     assert stereo == (self.__channels == 2)
     if stereo:
         joiner = blocks.streams_to_vector(gr.sizeof_float, 2)
         self.connect(l_endpoint, (joiner, 0), self)
         self.connect(r_endpoint, (joiner, 1))
     else:
         self.connect(l_endpoint, self)
コード例 #7
0
ファイル: basic_demod.py プロジェクト: bitglue/shinysdr
 def connect_audio_output(self, l_endpoint, r_endpoint=None):
     stereo = r_endpoint is not None
     assert stereo == (self.__channels == 2)
     if stereo:
         joiner = blocks.streams_to_vector(gr.sizeof_float, 2)
         self.connect(l_endpoint, (joiner, 0), self)
         self.connect(r_endpoint, (joiner, 1))
     else:
         self.connect(l_endpoint, self)
コード例 #8
0
 def connect_audio_output(self, l_endpoint, r_endpoint=None):
     # TODO: Convert this into a separate helper function?
     stereo = r_endpoint is not None
     assert stereo == (self.__channels == 2)
     if stereo:
         joiner = blocks.streams_to_vector(gr.sizeof_float, 2)
         self.connect(l_endpoint, (joiner, 0), self)
         self.connect(r_endpoint, (joiner, 1))
     else:
         self.connect(l_endpoint, self)
コード例 #9
0
ファイル: basic_demod.py プロジェクト: kpreid/shinysdr
 def connect_audio_output(self, l_endpoint, r_endpoint=None):
     # TODO: Convert this into a separate helper function?
     stereo = r_endpoint is not None
     assert stereo == (self.__channels == 2)
     if stereo:
         joiner = blocks.streams_to_vector(gr.sizeof_float, 2)
         self.connect(l_endpoint, (joiner, 0), self)
         self.connect(r_endpoint, (joiner, 1))
     else:
         self.connect(l_endpoint, self)
コード例 #10
0
    def __do_connect(self, reason):
        # log.msg(u'receiver do_connect: %s' % (reason,))
        self.context.lock()
        try:
            self.disconnect_all()

            # Connect input of demodulator
            if self.__demod_tunable:
                self.connect(self, self.__demodulator)
            else:
                self.connect(self, self.__rotator, self.__demodulator)

            if self.__demod_output:
                # Construct stereo-to-mono conversion (used at least for level probe)
                if self.__demod_stereo:
                    splitter = blocks.vector_to_streams(gr.sizeof_float, 2)
                    mono_audio = blocks.multiply_matrix_ff(((0.5, 0.5), ))
                    self.connect(self.__demodulator, splitter)
                    self.connect((splitter, 0), (mono_audio, 0))
                    self.connect((splitter, 1), (mono_audio, 1))
                else:
                    mono_audio = self.__demodulator

                # Connect mono audio to level probe
                self.connect(mono_audio, self.probe_audio)

                # Connect demodulator to output gain control, converting as needed
                if (self.__audio_channels == 2) == self.__demod_stereo:
                    # stereo to stereo or mono to mono
                    self.connect(self.__demodulator, self.__audio_gain_block)
                elif self.__audio_channels == 2 and not self.__demod_stereo:
                    # mono to stereo
                    duplicator = blocks.streams_to_vector(gr.sizeof_float, 2)
                    self.connect(self.__demodulator, (duplicator, 0))
                    self.connect(self.__demodulator, (duplicator, 1))
                    self.connect(duplicator, self.__audio_gain_block)
                elif self.__audio_channels == 1 and self.__demod_stereo:
                    # stereo to mono
                    self.connect(mono_audio, self.__audio_gain_block)
                else:
                    raise Exception('shouldn\'t happen')

                # Connect gain control to output of receiver
                self.connect(self.__audio_gain_block, self)
            else:
                # Dummy output, ignored by containing block
                self.connect(
                    blocks.vector_source_f([], vlen=self.__audio_channels),
                    self)

            if self.__output_type != self.__last_output_type:
                self.__last_output_type = self.__output_type
                self.context.changed_needed_connections(u'changed output type')
        finally:
            self.context.unlock()
コード例 #11
0
ファイル: receiver.py プロジェクト: thefinn93/shinysdr
 def __do_connect(self, reason):
     # log.msg(u'receiver do_connect: %s' % (reason,))
     self.context.lock()
     try:
         self.disconnect_all()
         
         # Connect input of demodulator
         if self.__demod_tunable:
             self.connect(self, self.__demodulator)
         else:
             self.connect(self, self.__rotator, self.__demodulator)
         
         if self.__demod_output:
             # Construct stereo-to-mono conversion (used at least for level probe)
             if self.__demod_stereo:
                 splitter = blocks.vector_to_streams(gr.sizeof_float, 2)
                 mono_audio = blocks.multiply_matrix_ff(((0.5, 0.5),))
                 self.connect(self.__demodulator, splitter)
                 self.connect((splitter, 0), (mono_audio, 0))
                 self.connect((splitter, 1), (mono_audio, 1))
             else:
                 mono_audio = self.__demodulator
             
             # Connect mono audio to level probe
             self.connect(mono_audio, self.probe_audio)
             
             # Connect demodulator to output gain control, converting as needed
             if (self.__audio_channels == 2) == self.__demod_stereo:
                 # stereo to stereo or mono to mono
                 self.connect(self.__demodulator, self.__audio_gain_block)
             elif self.__audio_channels == 2 and not self.__demod_stereo:
                 # mono to stereo
                 duplicator = blocks.streams_to_vector(gr.sizeof_float, 2)
                 self.connect(self.__demodulator, (duplicator, 0))
                 self.connect(self.__demodulator, (duplicator, 1))
                 self.connect(duplicator, self.__audio_gain_block)
             elif self.__audio_channels == 1 and self.__demod_stereo:
                 # stereo to mono
                 self.connect(mono_audio, self.__audio_gain_block)
             else:
                 raise Exception('shouldn\'t happen')
                 
             # Connect gain control to output of receiver
             self.connect(self.__audio_gain_block, self)
         else:
             # Dummy output, ignored by containing block
             self.connect(
                 blocks.vector_source_f([], vlen=self.__audio_channels),
                 self)
         
         if self.__output_type != self.__last_output_type:
             self.__last_output_type = self.__output_type
             self.context.changed_needed_connections(u'changed output type')
     finally:
         self.context.unlock()
コード例 #12
0
ファイル: top.py プロジェクト: LucaBongiorni/shinysdr
	def add_audio_queue(self, queue, queue_rate):
		# TODO: place limit on maximum requested sample rate
		sink = blocks.message_sink(
			gr.sizeof_float * num_audio_channels,
			queue,
			True)
		interleaver = blocks.streams_to_vector(gr.sizeof_float, num_audio_channels)
		# TODO: bundle the interleaver and sink in a hier block so it doesn't have to be reconnected
		self.audio_queue_sinks[queue] = (queue_rate, interleaver, sink)
		
		self.__needs_reconnect = True
		self._do_connect()
		self.__start_or_stop()
コード例 #13
0
ファイル: audiomux.py プロジェクト: hofschroeer/shinysdr
 def __init__(self, channels, queue):
     gr.hier_block2.__init__(
         self,
         "ShinySDR AudioQueueSink",
         gr.io_signature(channels, channels, gr.sizeof_float),
         gr.io_signature(0, 0, 0),
     )
     sink = blocks.message_sink(gr.sizeof_float * channels, queue, True)
     if channels == 1:
         self.connect((self, 0), sink)
     else:
         interleaver = blocks.streams_to_vector(gr.sizeof_float, channels)
         for ch in xrange(channels):
             self.connect((self, ch), (interleaver, ch))
         self.connect(interleaver, sink)
コード例 #14
0
ファイル: audiomux.py プロジェクト: misterdevil/shinysdr
 def __init__(self, channels, queue):
     gr.hier_block2.__init__(
         self,
         'ShinySDR AudioQueueSink',
         gr.io_signature(channels, channels, gr.sizeof_float),
         gr.io_signature(0, 0, 0),
     )
     sink = blocks.message_sink(gr.sizeof_float * channels, queue, True)
     if channels == 1:
         self.connect((self, 0), sink)
     else:
         interleaver = blocks.streams_to_vector(gr.sizeof_float, channels)
         for ch in xrange(channels):
             self.connect((self, ch), (interleaver, ch))
         self.connect(interleaver, sink)
コード例 #15
0
    def __init__(self, mpoints, taps=None):
        """
        Takes 1 complex stream in, produces M complex streams out
        that runs at 1/M times the input sample rate

        Args:
            mpoints: number of freq bins/interpolation factor/subbands
            taps: filter taps for subband filter

        Same channel to frequency mapping as described above.
        """
        item_size = gr.sizeof_gr_complex
        gr.hier_block2.__init__(
            self,
            "analysis_filterbank",
            gr.io_signature(1, 1, item_size),  # Input signature
            gr.io_signature(mpoints, mpoints, item_size))  # Output signature

        if taps is None:
            taps = _generate_synthesis_taps(mpoints)

        # pad taps to multiple of mpoints
        r = len(taps) % mpoints
        if r != 0:
            taps = taps + (mpoints - r) * (0, )

        # split in mpoints separate set of taps
        sub_taps = _split_taps(taps, mpoints)

        # print(>> sys.stderr, "mpoints =", mpoints, "len(sub_taps) =", len(sub_taps))

        self.s2ss = blocks.stream_to_streams(item_size, mpoints)
        # filters here
        self.ss2v = blocks.streams_to_vector(item_size, mpoints)
        self.fft = fft.fft_vcc(mpoints, True, [])
        self.v2ss = blocks.vector_to_streams(item_size, mpoints)

        self.connect(self, self.s2ss)

        # build mpoints fir filters...
        for i in range(mpoints):
            f = fft_filter_ccc(1, sub_taps[mpoints - i - 1])
            self.connect((self.s2ss, i), f)
            self.connect(f, (self.ss2v, i))
            self.connect((self.v2ss, i), (self, i))

        self.connect(self.ss2v, self.fft, self.v2ss)
コード例 #16
0
ファイル: filterbank.py プロジェクト: 0x7678/gnuradio-wg-grc
    def __init__(self, mpoints, taps=None):
        """
        Takes 1 complex stream in, produces M complex streams out
        that runs at 1/M times the input sample rate

        Args:
            mpoints: number of freq bins/interpolation factor/subbands
            taps: filter taps for subband filter

        Same channel to frequency mapping as described above.
        """
        item_size = gr.sizeof_gr_complex
        gr.hier_block2.__init__(self, "analysis_filterbank",
                                gr.io_signature(1, 1, item_size),             # Input signature
                                gr.io_signature(mpoints, mpoints, item_size)) # Output signature

        if taps is None:
            taps = _generate_synthesis_taps(mpoints)

        # pad taps to multiple of mpoints
        r = len(taps) % mpoints
        if r != 0:
            taps = taps + (mpoints - r) * (0,)

        # split in mpoints separate set of taps
        sub_taps = _split_taps(taps, mpoints)

        # print >> sys.stderr, "mpoints =", mpoints, "len(sub_taps) =", len(sub_taps)

        self.s2ss = blocks.stream_to_streams(item_size, mpoints)
        # filters here
        self.ss2v = blocks.streams_to_vector(item_size, mpoints)
        self.fft = fft.fft_vcc(mpoints, True, [])
        self.v2ss = blocks.vector_to_streams(item_size, mpoints)

        self.connect(self, self.s2ss)

        # build mpoints fir filters...
        for i in range(mpoints):
            f = fft_filter_ccc(1, sub_taps[mpoints-i-1])
            self.connect((self.s2ss, i), f)
            self.connect(f, (self.ss2v, i))
            self.connect((self.v2ss, i), (self, i))

        self.connect(self.ss2v, self.fft, self.v2ss)
コード例 #17
0
ファイル: basic_demod.py プロジェクト: bitglue/shinysdr
    def __init__(self, mode, input_rate, context):
        channels = 2
        audio_rate = 10000
        
        gr.hier_block2.__init__(
            self, str('%s demodulator' % (mode,)),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_float * channels))

        self.__input_rate = input_rate
        self.__rec_freq_input = 0.0
        self.__signal_type = SignalType(kind='STEREO', sample_rate=audio_rate)

        # Using agc2 rather than feedforward AGC for efficiency, because this runs at the RF rate rather than the audio rate.
        agc_block = analog.agc2_cc(reference=dB(-8))
        agc_block.set_attack_rate(8e-3)
        agc_block.set_decay_rate(8e-3)
        agc_block.set_max_gain(dB(40))
        
        self.connect(
            self,
            agc_block)
        
        channel_joiner = blocks.streams_to_vector(gr.sizeof_float, channels)
        self.connect(channel_joiner, self)
        
        for channel in xrange(0, channels):
            self.connect(
                agc_block,
                grfilter.fir_filter_ccc(1, design_sawtooth_filter(decreasing=channel == 0)),
                blocks.complex_to_mag(1),
                blocks.float_to_complex(),  # So we can use the complex-input band filter. TODO eliminate this for efficiency
                MultistageChannelFilter(
                    input_rate=input_rate,
                    output_rate=audio_rate,
                    cutoff_freq=5000,
                    transition_width=5000),
                blocks.complex_to_real(),
                # assuming below 40Hz is not of interest
                grfilter.dc_blocker_ff(audio_rate // 40, False),
                (channel_joiner, channel))
コード例 #18
0
    def __init__(self, mode, input_rate, context):
        channels = 2
        audio_rate = 10000
        
        gr.hier_block2.__init__(
            self, str('%s demodulator' % (mode,)),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_float * channels))

        self.__input_rate = input_rate
        self.__rec_freq_input = 0.0
        self.__signal_type = SignalType(kind='STEREO', sample_rate=audio_rate)

        # Using agc2 rather than feedforward AGC for efficiency, because this runs at the RF rate rather than the audio rate.
        agc_block = analog.agc2_cc(reference=dB(-8))
        agc_block.set_attack_rate(8e-3)
        agc_block.set_decay_rate(8e-3)
        agc_block.set_max_gain(dB(40))
        
        self.connect(
            self,
            agc_block)
        
        channel_joiner = blocks.streams_to_vector(gr.sizeof_float, channels)
        self.connect(channel_joiner, self)
        
        for channel in six.moves.range(0, channels):
            self.connect(
                agc_block,
                grfilter.fir_filter_ccc(1, design_sawtooth_filter(decreasing=channel == 0)),
                blocks.complex_to_mag(1),
                blocks.float_to_complex(),  # So we can use the complex-input band filter. TODO eliminate this for efficiency
                MultistageChannelFilter(
                    input_rate=input_rate,
                    output_rate=audio_rate,
                    cutoff_freq=5000,
                    transition_width=5000),
                blocks.complex_to_real(),
                # assuming below 40Hz is not of interest
                grfilter.dc_blocker_ff(audio_rate // 40, False),
                (channel_joiner, channel))
コード例 #19
0
ファイル: blocks.py プロジェクト: thefinn93/shinysdr
    def __init__(self, in_rate, out_rate, vlen, complex=False):
        # pylint: disable=redefined-builtin
        vitemsize = gr.sizeof_gr_complex if complex else gr.sizeof_float
        itemsize = vitemsize * vlen
        gr.hier_block2.__init__(
            self, type(self).__name__,
            gr.io_signature(1, 1, itemsize),
            gr.io_signature(1, 1, itemsize))

        if vlen == 1:
            self.connect(self, make_resampler(in_rate, out_rate, complex=complex), self)
        else:
            splitter = blocks.vector_to_streams(vitemsize, vlen)
            joiner = blocks.streams_to_vector(vitemsize, vlen)
            self.connect(self, splitter)
            for ch in xrange(vlen):
                self.connect(
                    (splitter, ch),
                    make_resampler(in_rate, out_rate, complex=complex),
                    (joiner, ch))
            self.connect(joiner, self)
コード例 #20
0
ファイル: qa_pipe_fittings.py プロジェクト: danbar/gnuradio
    def test_003(self):

        #Test streams_to_vector (using stream_to_streams & vector_to_stream).

        n = 8
        src_len = n * 8
        src_data = tuple(range(src_len))
        expected_results = src_data

        src = blocks.vector_source_i(src_data)
        op1 = blocks.stream_to_streams(gr.sizeof_int, n)
        op2 = blocks.streams_to_vector(gr.sizeof_int, n)
        op3 = blocks.vector_to_stream(gr.sizeof_int, n)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op1)
        for i in range(n):
            self.tb.connect((op1, i), (op2, i))
        self.tb.connect(op2, op3, dst)

        self.tb.run()
        self.assertEqual(expected_results, dst.data())
コード例 #21
0
ファイル: qa_pipe_fittings.py プロジェクト: yxw027/gnuradio
    def test_003(self):

        #Test streams_to_vector (using stream_to_streams & vector_to_stream).

        n = 8
        src_len = n * 8
        src_data = tuple(range(src_len))
        expected_results = src_data

        src = blocks.vector_source_i(src_data)
        op1 = blocks.stream_to_streams(gr.sizeof_int, n)
        op2 = blocks.streams_to_vector(gr.sizeof_int, n)
        op3 = blocks.vector_to_stream(gr.sizeof_int, n)
        dst = blocks.vector_sink_i()

        self.tb.connect(src, op1)
        for i in range(n):
            self.tb.connect((op1, i), (op2, i))
        self.tb.connect(op2, op3, dst)

        self.tb.run()
        self.assertEqual(expected_results, dst.data())
コード例 #22
0
ファイル: blocks.py プロジェクト: thejeshgn/shinysdr
    def __init__(self, in_rate, out_rate, vlen, complex=False):
        # pylint: disable=redefined-builtin
        vitemsize = gr.sizeof_gr_complex if complex else gr.sizeof_float
        itemsize = vitemsize * vlen
        gr.hier_block2.__init__(self,
                                type(self).__name__,
                                gr.io_signature(1, 1, itemsize),
                                gr.io_signature(1, 1, itemsize))

        if vlen == 1:
            self.connect(self,
                         make_resampler(in_rate, out_rate, complex=complex),
                         self)
        else:
            splitter = blocks.vector_to_streams(vitemsize, vlen)
            joiner = blocks.streams_to_vector(vitemsize, vlen)
            self.connect(self, splitter)
            for ch in six.moves.range(vlen):
                self.connect((splitter, ch),
                             make_resampler(in_rate, out_rate,
                                            complex=complex), (joiner, ch))
            self.connect(joiner, self)
コード例 #23
0
    def __init__(self, mpoints, taps=None):
        """
        Takes M complex streams in, produces single complex stream out
        that runs at M times the input sample rate

        Args:
            mpoints: number of freq bins/interpolation factor/subbands
            taps: filter taps for subband filter

        The channel spacing is equal to the input sample rate.
        The total bandwidth and output sample rate are equal the input
        sample rate * nchannels.

        Output stream to frequency mapping:

          channel zero is at zero frequency.

          if mpoints is odd:

            Channels with increasing positive frequencies come from
            channels 1 through (N-1)/2.

            Channel (N+1)/2 is the maximum negative frequency, and
            frequency increases through N-1 which is one channel lower
            than the zero frequency.

          if mpoints is even:

            Channels with increasing positive frequencies come from
            channels 1 through (N/2)-1.

            Channel (N/2) is evenly split between the max positive and
            negative bins.

            Channel (N/2)+1 is the maximum negative frequency, and
            frequency increases through N-1 which is one channel lower
            than the zero frequency.

            Channels near the frequency extremes end up getting cut
            off by subsequent filters and therefore have diminished
            utility.
        """
        item_size = gr.sizeof_gr_complex
        gr.hier_block2.__init__(self, "synthesis_filterbank",
                                gr.io_signature(mpoints, mpoints, item_size), # Input signature
                                gr.io_signature(1, 1, item_size))             # Output signature


        if taps is None:
            taps = _generate_synthesis_taps(mpoints)

        # pad taps to multiple of mpoints
        r = len(taps) % mpoints
        if r != 0:
            taps = taps + (mpoints - r) * (0,)

        # split in mpoints separate set of taps
        sub_taps = _split_taps(taps, mpoints)

        self.ss2v = blocks.streams_to_vector(item_size, mpoints)
        self.ifft = fft.fft_vcc(mpoints, False, [])
        self.v2ss = blocks.vector_to_streams(item_size, mpoints)
        # mpoints filters go in here...
        self.ss2s = blocks.streams_to_stream(item_size, mpoints)

        for i in range(mpoints):
            self.connect((self, i), (self.ss2v, i))

        self.connect(self.ss2v, self.ifft, self.v2ss)

        # build mpoints fir filters...
        for i in range(mpoints):
            f = fft_filter_ccc(1, sub_taps[i])
            self.connect((self.v2ss, i), f)
            self.connect(f, (self.ss2s, i))

            self.connect(self.ss2s, self)
コード例 #24
0
    def __init__(self, filename):
        gr.top_block.__init__(self, "Usrp Sink Vector")

        ##################################################
        # Variables
        ##################################################
        self.filename = filename
        self.samp_rate = samp_rate = 2e6
        self.TX_freqs = TX_freqs = (1e5, 1.5e5, 2e5, 2.5e5, 3e5, 3.5e5, 4e5,
                                    4.5e5, 5e5, 5.5e5, 6e5, 6.5e5, 7e5, 7.5e5,
                                    8e5)

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(0, 0)
        self.uhd_usrp_source_0_0.set_gain(0, 0)
        self.multi_goertzel_0 = multi_goertzel(
            freqs=self.TX_freqs,
            goertzel_size=2048,
            mult=2,
            samp_rate=int(samp_rate),
        )
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 15)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 15,
                                                   filename, False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_streams_to_vector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.multi_goertzel_0, 0),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.multi_goertzel_0, 1),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.multi_goertzel_0, 10),
                     (self.blocks_streams_to_vector_0, 10))
        self.connect((self.multi_goertzel_0, 11),
                     (self.blocks_streams_to_vector_0, 11))
        self.connect((self.multi_goertzel_0, 12),
                     (self.blocks_streams_to_vector_0, 12))
        self.connect((self.multi_goertzel_0, 13),
                     (self.blocks_streams_to_vector_0, 13))
        self.connect((self.multi_goertzel_0, 14),
                     (self.blocks_streams_to_vector_0, 14))
        self.connect((self.multi_goertzel_0, 2),
                     (self.blocks_streams_to_vector_0, 2))
        self.connect((self.multi_goertzel_0, 3),
                     (self.blocks_streams_to_vector_0, 3))
        self.connect((self.multi_goertzel_0, 4),
                     (self.blocks_streams_to_vector_0, 4))
        self.connect((self.multi_goertzel_0, 5),
                     (self.blocks_streams_to_vector_0, 5))
        self.connect((self.multi_goertzel_0, 6),
                     (self.blocks_streams_to_vector_0, 6))
        self.connect((self.multi_goertzel_0, 7),
                     (self.blocks_streams_to_vector_0, 7))
        self.connect((self.multi_goertzel_0, 8),
                     (self.blocks_streams_to_vector_0, 8))
        self.connect((self.multi_goertzel_0, 9),
                     (self.blocks_streams_to_vector_0, 9))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.multi_goertzel_0, 0))
コード例 #25
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 = 15e6
        self.integration_bandwidth = integration_bandwidth = 2.5e3
        self.if_bandwidth_2 = if_bandwidth_2 = .75e6
        self.dec_rate_1 = dec_rate_1 = 5
        self.samp_rate_2 = samp_rate_2 = samp_rate / dec_rate_1
        self.num_channels = num_channels = int(if_bandwidth_2 /
                                               integration_bandwidth)
        self.samp_rate_3 = samp_rate_3 = samp_rate_2 / num_channels
        self.integration_time = integration_time = .5
        self.variable_function_probe = variable_function_probe = 0
        self.output_samp_rate = output_samp_rate = 1.0 / integration_time
        self.integration_dec_rate = integration_dec_rate = int(
            integration_time * samp_rate_3 / 2)
        self.if_bandwidth_0 = if_bandwidth_0 = 4.5e6
        self.gain = gain = 60
        self.freq = freq = 1.4204e9
        self.channel_map = channel_map = range(
            int(num_channels / 2.0 + 1.0), num_channels, 1) + range(
                0, int(num_channels / 2.0 + 1.0), 1)

        ##################################################
        # Blocks
        ##################################################
        self.probe_signal = blocks.probe_signal_vf(num_channels)
        self._gain_range = Range(0, 70, 1, 60, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain",
                                     "counter_slider", int)
        self.top_layout.addWidget(self._gain_win)

        def _variable_function_probe_probe():
            while True:
                val = self.probe_signal.level()
                try:
                    self.set_variable_function_probe(val)
                except AttributeError:
                    pass
                pytime.sleep(1.0 / (10))

        _variable_function_probe_thread = threading.Thread(
            target=_variable_function_probe_probe)
        _variable_function_probe_thread.daemon = True
        _variable_function_probe_thread.start()

        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(
            num_channels,
            (firdes.low_pass(1, samp_rate_2, integration_bandwidth, 250,
                             firdes.WIN_HAMMING)), 1.0, 0)
        self.pfb_channelizer_ccf_0.set_channel_map((channel_map))
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)

        self.low_pass_filter_1 = filter.fir_filter_ccf(
            dec_rate_1,
            firdes.low_pass(10, samp_rate, if_bandwidth_2, 1e5,
                            firdes.WIN_HAMMING, 6.76))
        self.limesdr_source_2 = limesdr.source('0009072C02873717', 2, 1, 0, 0,
                                               '', freq - 800e3, samp_rate, 0,
                                               1, 15e6, 0, 10e6, 3, 2, 2, 1,
                                               if_bandwidth_0, 1, 5e6, 1,
                                               if_bandwidth_0, 0, 0, gain, 30,
                                               0, 0, 0, 0)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, num_channels)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_integrate_xx_0_0 = blocks.integrate_ff(
            integration_dec_rate, num_channels)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 1,
            '/home/w1xm-admin/Documents/DSP/data_out/recieve_block_sink',
            False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_copy_0_0 = blocks.copy(gr.sizeof_gr_complex * 1)
        self.blocks_copy_0_0.set_enabled(False)
        self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex * 1)
        self.blocks_copy_0.set_enabled(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(
            num_channels)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_SIN_WAVE, -800e3, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_integrate_xx_0_0, 0))
        self.connect((self.blocks_copy_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_copy_0_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.probe_signal, 0))
        self.connect((self.blocks_multiply_xx_1, 0),
                     (self.low_pass_filter_1, 0))
        self.connect((self.blocks_streams_to_vector_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.limesdr_source_2, 0), (self.blocks_copy_0, 0))
        self.connect((self.limesdr_source_2, 0), (self.blocks_copy_0_0, 0))
        self.connect((self.low_pass_filter_1, 0),
                     (self.pfb_channelizer_ccf_0, 0))

        for i in range(num_channels):
            self.connect((self.pfb_channelizer_ccf_0, i),
                         (self.blocks_streams_to_vector_0, i))
コード例 #26
0
ファイル: top_block.py プロジェクト: ETAChalmers/grc-noaa
    def __init__(self):
        gr.top_block.__init__(self, "udp-recive")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("udp-recive")
        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 = 850e3
        self.dec = dec = 25
        self.freq_0 = freq_0 = 137.50625e6
        self.bandwidth = bandwidth = 34e3
        self.RF_gain = RF_gain = 40
        self.Out_samprate = Out_samprate = samp_rate / dec
        self.NOAA19 = NOAA19 = -0.40625e6
        self.NOAA18 = NOAA18 = 0.40625e6
        self.NOAA15 = NOAA15 = 0.11375e6
        self.IF_gain = IF_gain = 40

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=11025,
            decimation=34000,
            taps=None,
            fractional_bw=None)
        self.qtgui_sink_x_0 = qtgui.sink_c(
            2048,  #fftsize
            firdes.WIN_HAMMING,  #wintype
            0,  #fc
            34e3,  #bw
            "output sink",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False  #plotconst
        )
        self.qtgui_sink_x_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0.enable_rf_freq(False)

        self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win)
        self.qtgui_sink_x_0.set_block_alias("output sink")
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_short, 0,
                                                     qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0.set_update_time(0.1)
        self.qtgui_number_sink_0.set_title("Selected channel")

        labels = ['', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

        for i in range(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 2)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win)
        self.blocks_udp_source_0_2 = blocks.udp_source(
            gr.sizeof_gr_complex * 1, '0.0.0.0', 1232, 4000, True)
        self.blocks_udp_source_0_1 = blocks.udp_source(
            gr.sizeof_gr_complex * 1, '0.0.0.0', 1230, 4000, True)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1,
                                                     '0.0.0.0', 1231, 4000,
                                                     True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1,
                                                 'localhost', 7355, 1225, True)
        self.blocks_threshold_ff_0_1 = blocks.threshold_ff(1.5, 2.5, 0)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(0.5, 1.5, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.5, 0.5, 0)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 3)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_short * 1)
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_moving_average_2_0 = blocks.moving_average_ff(
            4000, 1, 4000, 1)
        self.blocks_moving_average_2 = blocks.moving_average_ff(
            4000, 1, 4000, 1)
        self.blocks_moving_average_1 = blocks.moving_average_ff(
            4000, 1, 4000, 1)
        self.blocks_float_to_complex_1_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_complex_to_mag_squared_0_1 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.blocks_argmax_xx_0 = blocks.argmax_fs(3)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_0_0_0 = blocks.add_const_ff(-1)
        self.blocks_add_const_vxx_0_0 = blocks.add_const_ff(-1)
        self.blocks_add_const_vxx_0 = blocks.add_const_ff(-1)
        self.blocks_abs_xx_0_0_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_0_0 = blocks.abs_ff(1)
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.analog_wfm_rcv_0 = analog.wfm_rcv(
            quad_rate=bandwidth,
            audio_decimation=1,
        )
        self.NOAA19_fall = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq_0 + NOAA19,  #fc
            Out_samprate,  #bw
            "NOAA19 (stream 0)",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False  #plotconst
        )
        self.NOAA19_fall.set_update_time(1.0 / 1)
        self._NOAA19_fall_win = sip.wrapinstance(self.NOAA19_fall.pyqwidget(),
                                                 Qt.QWidget)

        self.NOAA19_fall.enable_rf_freq(True)

        self.top_grid_layout.addWidget(self._NOAA19_fall_win)
        self.NOAA18_fall = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq_0 + NOAA18,  #fc
            Out_samprate,  #bw
            "NOAA18 (stream 1)",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False  #plotconst
        )
        self.NOAA18_fall.set_update_time(1.0 / 1)
        self._NOAA18_fall_win = sip.wrapinstance(self.NOAA18_fall.pyqwidget(),
                                                 Qt.QWidget)

        self.NOAA18_fall.enable_rf_freq(True)

        self.top_grid_layout.addWidget(self._NOAA18_fall_win)
        self.NOAA15_fall = qtgui.sink_c(
            1024,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            freq_0 + NOAA15,  #fc
            Out_samprate,  #bw
            "NOAA15 (stream 2)",  #name
            True,  #plotfreq
            True,  #plotwaterfall
            False,  #plottime
            False  #plotconst
        )
        self.NOAA15_fall.set_update_time(1.0 / 1)
        self._NOAA15_fall_win = sip.wrapinstance(self.NOAA15_fall.pyqwidget(),
                                                 Qt.QWidget)

        self.NOAA15_fall.enable_rf_freq(True)

        self.top_grid_layout.addWidget(self._NOAA15_fall_win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_wfm_rcv_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_abs_xx_0_0, 0),
                     (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_abs_xx_0_0_0, 0),
                     (self.blocks_float_to_complex_1_1, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0, 0),
                     (self.blocks_abs_xx_0_0, 0))
        self.connect((self.blocks_add_const_vxx_0_0_0, 0),
                     (self.blocks_abs_xx_0_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.analog_wfm_rcv_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_sink_x_0, 0))
        self.connect((self.blocks_argmax_xx_0, 1),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_argmax_xx_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_0, 0),
                     (self.blocks_moving_average_1, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0),
                     (self.blocks_moving_average_2, 0))
        self.connect((self.blocks_complex_to_mag_squared_0_1, 0),
                     (self.blocks_moving_average_2_0, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_float_to_complex_1_1, 0),
                     (self.blocks_multiply_xx_2, 1))
        self.connect((self.blocks_moving_average_1, 0),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.blocks_moving_average_2, 0),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.blocks_moving_average_2_0, 0),
                     (self.blocks_streams_to_vector_0, 2))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_0, 2))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.blocks_threshold_ff_0_1, 0))
        self.connect((self.blocks_streams_to_vector_0, 0),
                     (self.blocks_argmax_xx_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_add_const_vxx_0_0, 0))
        self.connect((self.blocks_threshold_ff_0_1, 0),
                     (self.blocks_add_const_vxx_0_0_0, 0))
        self.connect((self.blocks_udp_source_0, 0), (self.NOAA19_fall, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_complex_to_mag_squared_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_udp_source_0_1, 0), (self.NOAA18_fall, 0))
        self.connect((self.blocks_udp_source_0_1, 0),
                     (self.blocks_complex_to_mag_squared_0_0, 0))
        self.connect((self.blocks_udp_source_0_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_udp_source_0_2, 0), (self.NOAA15_fall, 0))
        self.connect((self.blocks_udp_source_0_2, 0),
                     (self.blocks_complex_to_mag_squared_0_1, 0))
        self.connect((self.blocks_udp_source_0_2, 0),
                     (self.blocks_multiply_xx_2, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_udp_sink_0, 0))
コード例 #27
0
    def __init__(self, freq=145.95e6, gain=38):
        gr.top_block.__init__(self, "MOVE II")

        ##################################################
        # Parameters
        ##################################################
        self.freq = freq
        self.gain = gain

        ##################################################
        # Variables
        ##################################################
        self.doppler_freq = doppler_freq = freq
        self.samp_rate_rtlsdr = samp_rate_rtlsdr = 1536000
        self.samp_rate = samp_rate = 128000
        self.filename = filename = "iq_{0}_f{1}_g{2}".format(
            time.strftime("%Y-%m-%d_%H-%M-%S"), int(freq), gain)
        self.doppler_shift = doppler_shift = doppler_freq - freq
        self.decim = decim = 8

        ##################################################
        # Blocks
        ##################################################
        self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(
            samp_rate, 0.0, 5, 2048, filename + ".wf", 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=int(samp_rate_rtlsdr / samp_rate),
            taps=None,
            fractional_bw=None,
        )
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               '')
        self.osmosdr_source_0.set_sample_rate(samp_rate_rtlsdr)
        self.osmosdr_source_0.set_center_freq(freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(gain, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq,
                                                   "0.0.0.0", 4532, True)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1,
                                                 '127.0.0.1', 12345, 1472,
                                                 False)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex * 2,
                                                     filename + ".raw_dpl",
                                                     False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.analog_sig_source_x_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, doppler_shift, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.satnogs_waterfall_sink_0, 0))
        self.connect((self.blocks_streams_to_vector_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.blocks_streams_to_vector_0, 0))
コード例 #28
0
    def __init__(self):
        gr.top_block.__init__(self, "HF channel simulation")

        ##################################################
        # Variables
        ##################################################
        self.snr = snr = 40
        self.vol = vol = [1, 1]
        self.tau_a = tau_a = 1 / 100.
        self.tau = tau = 0.1
        self.snrVecOut = snrVecOut = ([0] * 3)
        self.samp_rate = samp_rate = 48000
        self.outSigRMSVec = outSigRMSVec = ([0] * 2)
        self.noSpread = noSpread = 0
        self.kN = kN = pow(10.0, (-snr / 20.0))
        self.freqShift = freqShift = 0.0
        self.fd = fd = 1
        self.en_noise = en_noise = [0, 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, 1.0], [1.0, 1.0]]

        ##################################################
        # Blocks
        ##################################################
        self.snrOut = blocks.probe_signal_vf(4)
        self.outSigRMS = blocks.probe_signal_vf(2)

        def _snrVecOut_probe():
            while True:

                val = self.snrOut.level()
                try:
                    self.set_snrVecOut(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _snrVecOut_thread = threading.Thread(target=_snrVecOut_probe)
        _snrVecOut_thread.daemon = True
        _snrVecOut_thread.start()

        self.single_pole_iir_filter_xx_0_1 = filter.single_pole_iir_filter_ff(
            2 * pi * tau_a / samp_rate, 1)
        self.single_pole_iir_filter_xx_0_0_0 = filter.single_pole_iir_filter_ff(
            2 * pi * tau_a / samp_rate, 1)
        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 _outSigRMSVec_probe():
            while True:

                val = self.outSigRMS.level()
                try:
                    self.set_outSigRMSVec(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))

        _outSigRMSVec_thread = threading.Thread(target=_outSigRMSVec_probe)
        _outSigRMSVec_thread.daemon = True
        _outSigRMSVec_thread.start()

        self.low_pass_filter_2_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1550, 100, firdes.WIN_HAMMING, 6.76))
        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_1 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[1][0] * (samp_rate / 100.0), samp_rate, 50,
                            25, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_1_0_0 = filter.interp_fir_filter_ccf(
            int(samp_rate / 100),
            firdes.low_pass(ampl[1][1] * (samp_rate / 100.0), samp_rate, 50,
                            25, 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_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 1750 + 100, 600, 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_0_0 = epy_block_0_0_0_0.blk(fd=fd)
        self.epy_block_0_0_0 = epy_block_0_0_0.blk(fd=fd)
        self.epy_block_0_0 = epy_block_0_0.blk(fd=fd)
        self.epy_block_0 = epy_block_0.blk(fd=fd)
        self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 2)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 4)
        self.blocks_selector_0_1 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                   noSpread, 0)
        self.blocks_selector_0_1.set_enabled(True)
        self.blocks_selector_0_0_0 = blocks.selector(gr.sizeof_gr_complex * 1,
                                                     noSpread, 0)
        self.blocks_selector_0_0_0.set_enabled(True)
        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_1 = blocks.rms_cf(2 * pi * tau_a * 100 /
                                               samp_rate)
        self.blocks_rms_xx_0_0_0 = blocks.rms_ff(2 * pi * tau_a * 10 /
                                                 samp_rate)
        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_null_source_0 = blocks.null_source(gr.sizeof_float * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0)
        self.blocks_multiply_xx_1_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_0_0 = 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_0 = blocks.multiply_const_ff(
            en_noise[1])
        self.blocks_multiply_const_vxx_3 = blocks.multiply_const_ff(
            en_noise[0])
        self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_cc(vol[1])
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_cc(vol[0])
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_ff(
            2 * sqrt(ampl[1][0]**2 + ampl[1][1]**2) * 2)
        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_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_divide_xx_1_0 = blocks.divide_ff(1)
        self.blocks_divide_xx_1 = blocks.divide_ff(1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                             int(tau * samp_rate))
        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_1 = blocks.complex_to_mag_squared(
            1)
        self.blocks_complex_to_mag_squared_2_0_0 = blocks.complex_to_mag_squared(
            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_0 = blocks.add_vff(1)
        self.blocks_add_xx_1 = blocks.add_vff(1)
        self.blocks_add_xx_0_1 = blocks.add_vcc(1)
        self.blocks_add_xx_0_0_0 = blocks.add_vcc(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, 'hw:CARD=Rubix44,DEV=0',
                                           False)
        self.audio_sink_0 = audio.sink(samp_rate, 'hw:CARD=Rubix44,DEV=0',
                                       False)
        self.analog_sig_source_x_3 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, 1000, 0.3, 0, 0)
        self.analog_sig_source_x_2_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 1, 0, 0)
        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_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, freqShift, 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_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1850, 1, 0, 0)
        self.analog_sig_source_x_0_0_0_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1850, 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_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1e-0 * kN, 13)
        self.analog_noise_source_x_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1e-0 * kN, 3)
        self.analog_noise_source_x_0_1 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 10)
        self.analog_noise_source_x_0_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 11)
        self.analog_noise_source_x_0_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 1, 0)
        self.analog_const_source_x_2_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_2 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 0, 0)
        self.analog_const_source_x_1_1 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[1][0])
        self.analog_const_source_x_1_0_0 = analog.sig_source_c(
            0, analog.GR_CONST_WAVE, 0, 0, ampl[1][1])
        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_0 = analog.sig_source_f(
            0, analog.GR_CONST_WAVE, 0, 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_0_0, 0),
                     (self.blocks_float_to_complex_0_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_1_0_0, 0),
                     (self.blocks_selector_0_0_0, 1))
        self.connect((self.analog_const_source_x_1_1, 0),
                     (self.blocks_selector_0_1, 1))
        self.connect((self.analog_const_source_x_2, 0),
                     (self.blocks_float_to_complex_1, 1))
        self.connect((self.analog_const_source_x_2_0, 0),
                     (self.blocks_float_to_complex_1_0, 1))
        self.connect((self.analog_noise_source_x_0, 0), (self.epy_block_0, 0))
        self.connect((self.analog_noise_source_x_0_0, 0),
                     (self.epy_block_0_0, 0))
        self.connect((self.analog_noise_source_x_0_0_0, 0),
                     (self.epy_block_0_0_0_0, 0))
        self.connect((self.analog_noise_source_x_0_1, 0),
                     (self.epy_block_0_0_0, 0))
        self.connect((self.analog_noise_source_x_1, 0),
                     (self.low_pass_filter_2, 0))
        self.connect((self.analog_noise_source_x_1_0, 0),
                     (self.low_pass_filter_2_0, 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_0_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_1, 1))
        self.connect((self.analog_sig_source_x_0_0_1, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.analog_sig_source_x_1, 0),
                     (self.blocks_multiply_xx_1, 0))
        self.connect((self.analog_sig_source_x_1_0, 0),
                     (self.blocks_multiply_xx_1_0, 0))
        self.connect((self.analog_sig_source_x_2, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 1))
        self.connect((self.analog_sig_source_x_2_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 1))
        self.connect((self.analog_sig_source_x_3, 0),
                     (self.blocks_multiply_const_vxx_3, 0))
        self.connect((self.analog_sig_source_x_3, 0),
                     (self.blocks_multiply_const_vxx_3_0, 0))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.audio_source_0, 1),
                     (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.audio_source_0, 2), (self.blocks_null_sink_0, 0))
        self.connect((self.audio_source_0, 3), (self.blocks_null_sink_0, 1))
        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_0_0_0, 0),
                     (self.blocks_multiply_const_vxx_2_0, 0))
        self.connect((self.blocks_add_xx_0_1, 0),
                     (self.blocks_multiply_xx_1_0, 1))
        self.connect((self.blocks_add_xx_1, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_xx_1_0, 0),
                     (self.blocks_multiply_const_vxx_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_mag_squared_2_0_0, 0),
                     (self.single_pole_iir_filter_xx_0_0_0, 0))
        self.connect((self.blocks_complex_to_mag_squared_2_1, 0),
                     (self.single_pole_iir_filter_xx_0_1, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_add_xx_1, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_add_xx_1_0, 1))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_1, 0))
        self.connect((self.blocks_divide_xx_1, 0),
                     (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_divide_xx_1_0, 0),
                     (self.blocks_nlog10_ff_0_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.blocks_float_to_complex_1, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 2))
        self.connect((self.blocks_float_to_complex_1_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 2))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.audio_sink_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_rms_xx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_rms_xx_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_1_0, 0),
                     (self.blocks_float_to_complex_1_0, 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_const_vxx_3_0, 0),
                     (self.blocks_add_xx_1_0, 0))
        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, 0),
                     (self.blocks_add_xx_0_0_0, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0_0, 0),
                     (self.blocks_complex_to_mag_squared_2_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0_1, 0),
                     (self.blocks_add_xx_0_1, 1))
        self.connect((self.blocks_multiply_xx_0_0_0_1, 0),
                     (self.blocks_add_xx_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_multiply_xx_0_0_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_0_1, 0),
                     (self.blocks_rms_xx_0_1, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.low_pass_filter_0_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_multiply_xx_1_0, 0),
                     (self.blocks_add_xx_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_1_0, 0),
                     (self.blocks_complex_to_mag_squared_2_1, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.blocks_streams_to_vector_0, 2))
        self.connect((self.blocks_nlog10_ff_0_0, 0),
                     (self.blocks_streams_to_vector_0, 3))
        self.connect((self.blocks_null_source_0, 0), (self.audio_sink_0, 2))
        self.connect((self.blocks_null_source_0, 1), (self.audio_sink_0, 3))
        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.blocks_streams_to_vector_0_0, 0))
        self.connect((self.blocks_rms_xx_0_0_0, 0),
                     (self.blocks_streams_to_vector_0_0, 1))
        self.connect((self.blocks_rms_xx_0_1, 0),
                     (self.blocks_multiply_const_vxx_1_0, 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.blocks_selector_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_1, 1))
        self.connect((self.blocks_selector_0_1, 0),
                     (self.blocks_multiply_xx_0_0_0_1, 1))
        self.connect((self.blocks_streams_to_vector_0, 0), (self.snrOut, 0))
        self.connect((self.blocks_streams_to_vector_0_0, 0),
                     (self.outSigRMS, 0))
        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.epy_block_0_0_0, 0), (self.low_pass_filter_1_1, 0))
        self.connect((self.epy_block_0_0_0_0, 0),
                     (self.low_pass_filter_1_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.blocks_multiply_xx_0_0_1, 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_1_0_0, 0),
                     (self.blocks_selector_0_0_0, 0))
        self.connect((self.low_pass_filter_1_1, 0),
                     (self.blocks_selector_0_1, 0))
        self.connect((self.low_pass_filter_2, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 0))
        self.connect((self.low_pass_filter_2_0, 0),
                     (self.blocks_multiply_xx_0_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),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0),
                     (self.blocks_divide_xx_1, 1))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0_0_0, 0),
                     (self.blocks_divide_xx_1_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0_1, 0),
                     (self.blocks_divide_xx_1_0, 0))
コード例 #29
0
    def __init__(self, x_var, y_var, filesink):
        gr.top_block.__init__(self, "SDVLC  Testbed Simulation")

        ##################################################
        # Parameters
        ##################################################
        self.CtCr = (1.402589, 1.400153, 1.389144, 1.386729, 1.367899,
                     1.353108, 1.338055, 1.320068, 1.297516, 1.276457,
                     1.261740, 1.247866, 1.233018, 1.200908, 1.184429,
                     1.169045, 1.155984, 1.142038, 1.127352, 1.111633,
                     1.096738, 1.081336, 1.067067, 1.053066, 1.038244,
                     1.023078, 1.007937, 0.99301, 0.977535, 0.961326, 0.940293,
                     0.908008, 0.856049)
        CtCr = self.CtCr
        self.filesink = filesink

        ##################################################
        # Variables
        ##################################################
        self.dZ = dZ = 2.05
        x_var = float(x_var)
        y_var = float(y_var)
        self.y_var = y_var
        self.x_var = x_var
        self.TX_coords = TX_coords = ((3.62, 1.28, dZ), (3.62, .84, dZ),
                                      (3.62, .32, dZ), (2.87, 1.28, dZ),
                                      (2.87, .84, dZ), (2.87, .32, dZ),
                                      (2.20, 1.28, dZ), (2.2, .84,
                                                         dZ), (2.2, .32, dZ),
                                      (1.48, 1.28, dZ), (1.48, .84,
                                                         dZ), (1.48, .32, dZ),
                                      (.825, 1.32, dZ), (.825, .84,
                                                         dZ), (.825, .32, dZ))
        self.distances = distances = (
            numpy.sqrt((x_var - TX_coords[0][0])**2 +
                       (y_var - TX_coords[0][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[1][0])**2 +
                       (y_var - TX_coords[1][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[2][0])**2 +
                       (y_var - TX_coords[2][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[3][0])**2 +
                       (y_var - TX_coords[3][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[4][0])**2 +
                       (y_var - TX_coords[4][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[5][0])**2 +
                       (y_var - TX_coords[5][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[6][0])**2 +
                       (y_var - TX_coords[6][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[7][0])**2 +
                       (y_var - TX_coords[7][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[8][0])**2 +
                       (y_var - TX_coords[8][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[9][0])**2 +
                       (y_var - TX_coords[9][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[10][0])**2 +
                       (y_var - TX_coords[10][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[11][0])**2 +
                       (y_var - TX_coords[11][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[12][0])**2 +
                       (y_var - TX_coords[12][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[13][0])**2 +
                       (y_var - TX_coords[13][1])**2 + (dZ**2)),
            numpy.sqrt((x_var - TX_coords[14][0])**2 +
                       (y_var - TX_coords[14][1])**2 + (dZ**2)))
        self.samp_rate = samp_rate = int(2e6)
        self.lam_order = lam_order = .88
        self.goertzel_size = goertzel_size = 2048
        self.angles = angles = (
            numpy.arccos(dZ / distances[0]) * (180 / math.pi),
            numpy.arccos(dZ / distances[1]) * (180 / math.pi),
            numpy.arccos(dZ / distances[2]) * (180 / math.pi),
            numpy.arccos(dZ / distances[3]) * (180 / math.pi),
            numpy.arccos(dZ / distances[4]) * (180 / math.pi),
            numpy.arccos(dZ / distances[4]) * (180 / math.pi),
            numpy.arccos(dZ / distances[5]) * (180 / math.pi),
            numpy.arccos(dZ / distances[6]) * (180 / math.pi),
            numpy.arccos(dZ / distances[7]) * (180 / math.pi),
            numpy.arccos(dZ / distances[8]) * (180 / math.pi),
            numpy.arccos(dZ / distances[9]) * (180 / math.pi),
            numpy.arccos(dZ / distances[10]) * (180 / math.pi),
            numpy.arccos(dZ / distances[11]) * (180 / math.pi),
            numpy.arccos(dZ / distances[12]) * (180 / math.pi),
            numpy.arccos(dZ / distances[14]) * (180 / math.pi),
            numpy.arccos(dZ / distances[14]) * (180 / math.pi))
        self.TX_freqs = TX_freqs = (1e5, 1.5e5, 2e5, 2.5e5, 3e5, 3.5e5, 4e5,
                                    4.5e5, 5e5, 5.5e5, 6e5, 6.5e5, 7e5, 7.5e5,
                                    8e5)
        self.TX_ampl = TX_ampl = .7

        ##################################################
        # Blocks
        ##################################################
        self.vlp_testbed_sources_0 = vlp_testbed_sources(
            CtCr=CtCr,
            TX_coords=TX_coords,
            TX_freqs=TX_freqs,
            angles=angles,
            dZ=dZ,
            distances=distances,
            lam_order=lam_order,
            noise_ampl=0,
            samp_rate=samp_rate,
            tx_ampl=TX_ampl,
            x_var=x_var,
            y_var=y_var,
        )
        self.vlp2_amp2d_ff_0 = vlp2.amp2d_ff(TX_ampl, dZ, 1, (CtCr), 1, 1, 1.1,
                                             1, 90, 15)
        self.multi_goertzel_0 = multi_goertzel(
            freqs=TX_freqs,
            goertzel_size=goertzel_size,
            mult=2,
            samp_rate=samp_rate,
        )
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 15)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 15,
                                                   self.filesink, False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_streams_to_vector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.multi_goertzel_0, 0), (self.vlp2_amp2d_ff_0, 0))
        self.connect((self.multi_goertzel_0, 1), (self.vlp2_amp2d_ff_0, 1))
        self.connect((self.multi_goertzel_0, 10), (self.vlp2_amp2d_ff_0, 10))
        self.connect((self.multi_goertzel_0, 11), (self.vlp2_amp2d_ff_0, 11))
        self.connect((self.multi_goertzel_0, 12), (self.vlp2_amp2d_ff_0, 12))
        self.connect((self.multi_goertzel_0, 13), (self.vlp2_amp2d_ff_0, 13))
        self.connect((self.multi_goertzel_0, 14), (self.vlp2_amp2d_ff_0, 14))
        self.connect((self.multi_goertzel_0, 2), (self.vlp2_amp2d_ff_0, 2))
        self.connect((self.multi_goertzel_0, 3), (self.vlp2_amp2d_ff_0, 3))
        self.connect((self.multi_goertzel_0, 4), (self.vlp2_amp2d_ff_0, 4))
        self.connect((self.multi_goertzel_0, 5), (self.vlp2_amp2d_ff_0, 5))
        self.connect((self.multi_goertzel_0, 6), (self.vlp2_amp2d_ff_0, 6))
        self.connect((self.multi_goertzel_0, 7), (self.vlp2_amp2d_ff_0, 7))
        self.connect((self.multi_goertzel_0, 8), (self.vlp2_amp2d_ff_0, 8))
        self.connect((self.multi_goertzel_0, 9), (self.vlp2_amp2d_ff_0, 9))
        self.connect((self.vlp2_amp2d_ff_0, 0),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.vlp2_amp2d_ff_0, 1),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.vlp2_amp2d_ff_0, 10),
                     (self.blocks_streams_to_vector_0, 10))
        self.connect((self.vlp2_amp2d_ff_0, 11),
                     (self.blocks_streams_to_vector_0, 11))
        self.connect((self.vlp2_amp2d_ff_0, 12),
                     (self.blocks_streams_to_vector_0, 12))
        self.connect((self.vlp2_amp2d_ff_0, 13),
                     (self.blocks_streams_to_vector_0, 13))
        self.connect((self.vlp2_amp2d_ff_0, 14),
                     (self.blocks_streams_to_vector_0, 14))
        self.connect((self.vlp2_amp2d_ff_0, 2),
                     (self.blocks_streams_to_vector_0, 2))
        self.connect((self.vlp2_amp2d_ff_0, 3),
                     (self.blocks_streams_to_vector_0, 3))
        self.connect((self.vlp2_amp2d_ff_0, 4),
                     (self.blocks_streams_to_vector_0, 4))
        self.connect((self.vlp2_amp2d_ff_0, 5),
                     (self.blocks_streams_to_vector_0, 5))
        self.connect((self.vlp2_amp2d_ff_0, 6),
                     (self.blocks_streams_to_vector_0, 6))
        self.connect((self.vlp2_amp2d_ff_0, 7),
                     (self.blocks_streams_to_vector_0, 7))
        self.connect((self.vlp2_amp2d_ff_0, 8),
                     (self.blocks_streams_to_vector_0, 8))
        self.connect((self.vlp2_amp2d_ff_0, 9),
                     (self.blocks_streams_to_vector_0, 9))
        self.connect((self.vlp_testbed_sources_0, 0),
                     (self.multi_goertzel_0, 0))
コード例 #30
0
ファイル: MIMO_TOP_FLOW.py プロジェクト: heimao0130/gr-lte
    def __init__(self):
        gr.top_block.__init__(self, "MIMO TOP FLOW")

        ##################################################
        # Variables
        ##################################################
        self.fftl = fftl = 128
        self.samp_rate = samp_rate = fftl*15e3
        self.rxant = rxant = 2
        self.resampler = resampler = 400
        self.frame_key = frame_key = "slot"
        self.N_rb_dl = N_rb_dl = 50

        ##################################################
        # Blocks
        ##################################################
        self.lte_mimo_sss_sync_0 = lte_mimo_sss_sync(
            N_rb_dl=N_rb_dl,
            rxant=rxant,
        )
        self.lte_mimo_pss_sync_0 = lte_mimo_pss_sync(
            rxant=rxant,
            synclen=5,
            fftlen=fftl,
        )
        self.lte_mimo_pss_based_frey_sync_0 = lte_mimo_pss_based_frey_sync(
            fftlen=fftl,
            rxant=rxant,
        )
        self.lte_mimo_ofdm_rx_0 = lte_mimo_ofdm_rx(
            N_rb_dl=N_rb_dl,
            ofdm_key=frame_key,
            fftlen=fftl,
            rxant=rxant,
        )
        self.lte_mimo_estimator_0 = lte_mimo_estimator(
            N_rb_dl=N_rb_dl,
            estimator_key=frame_key,
            initial_id=2,
            rxant=rxant,
        )
        self.lte_mimo_decode_pbch_0 = lte_mimo_decode_pbch(
            N_rb_dl=N_rb_dl,
            rxant=rxant,
        )
        self.blocks_vector_to_streams_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*2, samp_rate,True)
        self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*12 * N_rb_dl, 2)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*2, "/home/johannes/src/gr-lte/tests/lte_test_data_RX2_NRBDL6.dat", True)
        self.bch_decode_bch_hier_gr37_0 = decode_bch_hier_gr37()
        self.MIB = lte.mib_unpack_vbm("MIB")

        ##################################################
        # Connections
        ##################################################
        self.connect((self.lte_mimo_pss_sync_0, 1), (self.lte_mimo_pss_based_frey_sync_0, 1))
        self.connect((self.lte_mimo_pss_sync_0, 0), (self.lte_mimo_pss_based_frey_sync_0, 0))
        self.connect((self.lte_mimo_pss_based_frey_sync_0, 0), (self.lte_mimo_ofdm_rx_0, 0))
        self.connect((self.lte_mimo_pss_based_frey_sync_0, 1), (self.lte_mimo_ofdm_rx_0, 1))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_vector_to_streams_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 0), (self.lte_mimo_pss_sync_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 1), (self.lte_mimo_pss_sync_0, 1))
        self.connect((self.lte_mimo_ofdm_rx_0, 0), (self.lte_mimo_sss_sync_0, 0))
        self.connect((self.lte_mimo_ofdm_rx_0, 1), (self.lte_mimo_sss_sync_0, 1))
        self.connect((self.lte_mimo_decode_pbch_0, 0), (self.bch_decode_bch_hier_gr37_0, 0))
        self.connect((self.lte_mimo_estimator_0, 0), (self.lte_mimo_decode_pbch_0, 1))
        self.connect((self.lte_mimo_estimator_0, 1), (self.lte_mimo_decode_pbch_0, 2))
        self.connect((self.bch_decode_bch_hier_gr37_0, 1), (self.MIB, 1))
        self.connect((self.bch_decode_bch_hier_gr37_0, 0), (self.MIB, 0))
        self.connect((self.lte_mimo_sss_sync_0, 1), (self.blocks_streams_to_vector_0_0, 1))
        self.connect((self.lte_mimo_sss_sync_0, 0), (self.blocks_streams_to_vector_0_0, 0))
        self.connect((self.blocks_streams_to_vector_0_0, 0), (self.lte_mimo_estimator_0, 0))
        self.connect((self.blocks_streams_to_vector_0_0, 0), (self.lte_mimo_decode_pbch_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.lte_mimo_sss_sync_0, "cell_id", self.lte_mimo_estimator_0, "cell_id")
        self.msg_connect(self.lte_mimo_pss_sync_0, "N_id_2", self.lte_mimo_sss_sync_0, "N_id_2")
        self.msg_connect(self.lte_mimo_sss_sync_0, "cell_id", self.lte_mimo_decode_pbch_0, "cell_id")
コード例 #31
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.Nt = Nt = 2
        self.dft_coef = dft_coef = np.exp(-2 * np.pi * 1j / Nt)
        self.A = A = np.arange(Nt)[np.newaxis]
        self.tlen = tlen = 4000
        self.samp_rate = samp_rate = 100000
        self.dft_matrix = dft_matrix = np.power(dft_coef,
                                                np.dot(A.transpose(), A))
        self.scramble_2 = scramble_2 = 2 * np.random.random_integers(
            0, 1, size=(tlen, Nt)) - 1
        self.scramble_1 = scramble_1 = 2 * np.random.random_integers(
            0, 1, size=(tlen, Nt)) - 1
        self.prefix = prefix = '/home/zhe/gr-PWF/examples'
        self.noise = noise = [np.identity(Nt), np.identity(Nt)]
        self.max_iteration = max_iteration = 20
        self.interpo = interpo = samp_rate / 1000
        self.dft_pilot_seq = dft_pilot_seq = np.tile(dft_matrix,
                                                     (tlen / Nt, 1))
        self.Q = Q = 4
        self.L = L = 2
        self.sigmagenfile = sigmagenfile = prefix + '/sigmagens/sigmagen_10.bin'
        self.pulse = pulse = filter.firdes.root_raised_cosine(
            Q, Q, 1, 0.35, 11 * Q)
        self.prewhiten1 = prewhiten1 = np.linalg.pinv(noise[1])
        self.prewhiten0 = prewhiten0 = np.linalg.pinv(noise[0])
        self.pilot_seq_2 = pilot_seq_2 = np.multiply(dft_pilot_seq, scramble_2)
        self.pilot_seq_1 = pilot_seq_1 = np.multiply(dft_pilot_seq, scramble_1)
        self.pilot2file = pilot2file = prefix + '/pilots/pilot2_4000.bin'
        self.pilot1file = pilot1file = prefix + '/pilots/pilot1_4000.bin'
        self.payload_size = payload_size = 0
        self.npoints = npoints = max_iteration * interpo
        self.noise_hat = noise_hat = [np.identity(Nt), np.identity(Nt)]
        self.ichn_gain_dB = ichn_gain_dB = 10
        self.channelfile = channelfile = prefix + '/channels/2x2channel_10dB_3.bin'
        self.channel = channel = np.true_divide(
            np.random.standard_normal(size=(L, L, Nt, Nt)) +
            np.random.standard_normal(size=(L, L, Nt, Nt)) * 1j, np.sqrt(2))
        self.Pt = Pt = 100

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            npoints,  #size
            samp_rate,  #samp_rate
            "Strong Interference (ichn_gain = 10dB)",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.1)
        self.qtgui_time_sink_x_0.set_y_axis(0, 20)

        self.qtgui_time_sink_x_0.set_y_label("Weighted Sum-Rate (bits/s/Hz)",
                                             "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO,
                                                  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_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = [
            "Dual Link", "Identity Sigma", "", "", "", "", "", "", "", ""
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.phase_corrector_0_2 = phase_corrector(
            loop_bandwidth=2 * np.pi * 0.005,
            max_freq=2 * np.pi * 0.01,
            training_sequence=pilot_seq_1[:, 0],
        )
        self.phase_corrector_0_1_0 = phase_corrector(
            loop_bandwidth=2 * np.pi * 0.005,
            max_freq=2 * np.pi * 0.01,
            training_sequence=pilot_seq_2[:, 0],
        )
        self.phase_corrector_0_1 = phase_corrector(
            loop_bandwidth=2 * np.pi * 0.005,
            max_freq=2 * np.pi * 0.01,
            training_sequence=pilot_seq_2[:, 0],
        )
        self.phase_corrector_0_0_1 = phase_corrector(
            loop_bandwidth=2 * np.pi * 0.005,
            max_freq=2 * np.pi * 0.01,
            training_sequence=pilot_seq_1[:, 1],
        )
        self.phase_corrector_0_0_0_0 = phase_corrector(
            loop_bandwidth=2 * np.pi * 0.005,
            max_freq=2 * np.pi * 0.01,
            training_sequence=pilot_seq_2[:, 1],
        )
        self.phase_corrector_0_0_0 = phase_corrector(
            loop_bandwidth=2 * np.pi * 0.005,
            max_freq=2 * np.pi * 0.01,
            training_sequence=pilot_seq_2[:, 1],
        )
        self.phase_corrector_0_0 = phase_corrector(
            loop_bandwidth=2 * np.pi * 0.005,
            max_freq=2 * np.pi * 0.01,
            training_sequence=pilot_seq_1[:, 1],
        )
        self.phase_corrector_0 = phase_corrector(
            loop_bandwidth=2 * np.pi * 0.005,
            max_freq=2 * np.pi * 0.01,
            training_sequence=pilot_seq_1[:, 0],
        )
        self.interp_fir_filter_xxx_0_1_0 = filter.interp_fir_filter_ccc(
            Q, (pulse))
        self.interp_fir_filter_xxx_0_1_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_1 = filter.interp_fir_filter_ccc(
            Q, (pulse))
        self.interp_fir_filter_xxx_0_1.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(
            Q, (pulse))
        self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(Q, (pulse))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_1 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.blocks_vector_to_streams_1_2 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_vector_to_streams_1_1_1 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_vector_to_streams_1_1_0_0 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_vector_to_streams_1_1_0 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_vector_to_streams_1_1 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_vector_to_streams_1_0_0 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_vector_to_streams_1_0 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_vector_to_streams_1 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_vector_to_streams_0 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 4, 2)
        self.blocks_udp_source_1 = blocks.udp_source(gr.sizeof_gr_complex * 8,
                                                     "127.0.0.1", 1234, 1472,
                                                     True)
        self.blocks_udp_sink_1_0 = blocks.udp_sink(gr.sizeof_gr_complex * 8,
                                                   "127.0.0.1", 1234, 1472,
                                                   True)
        self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_gr_complex * 8,
                                                 "127.0.0.1", 1234, 1472, True)
        self.blocks_streams_to_vector_1_2 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_streams_to_vector_1_1_1 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_streams_to_vector_1_1_0_0 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_streams_to_vector_1_1_0 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_streams_to_vector_1_1 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_streams_to_vector_1_0_0 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_streams_to_vector_1_0 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_streams_to_vector_1 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 4, 2)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 4, 2)
        self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_float * 1, interpo)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, interpo)
        self.blocks_file_sink_0 = blocks.file_sink(
            gr.sizeof_gr_complex * 8,
            "/home/zhe/Dropbox/gnuradio_trunk/gnufiles/udp", False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.PWF_weighted_sum_rate_0 = PWF.weighted_sum_rate(
            L, Nt, Pt, channel, ichn_gain_dB, [1, 1], [prewhiten0, prewhiten1],
            False, channelfile)
        self.PWF_sigmagen_0 = PWF.sigmagen(L, Nt, Pt, True, sigmagenfile)
        self.PWF_power_adjust_1_0 = PWF.power_adjust(Nt, Pt, L)
        self.PWF_power_adjust_1 = PWF.power_adjust(Nt, Pt, L)
        self.PWF_pilot_receive_tx_0_0 = PWF.pilot_receive_tx(
            True, pilot1file, pilot_seq_1, Nt, tlen, noise_hat[0], tlen, 1)
        self.PWF_pilot_receive_tx_0 = PWF.pilot_receive_tx(
            True, pilot2file, pilot_seq_2, Nt, tlen, noise_hat[1], tlen, 1)
        self.PWF_pilot_receive_rx_0_0 = PWF.pilot_receive_rx(
            True, pilot2file, pilot_seq_2, prewhiten1, Nt, tlen,
            tlen + payload_size, 1)
        self.PWF_pilot_receive_rx_0 = PWF.pilot_receive_rx(
            True, pilot1file, pilot_seq_1, prewhiten0, Nt, tlen,
            tlen + payload_size, 1)
        self.PWF_pilot_gen_tx_0_0 = PWF.pilot_gen_tx(Nt, tlen, pilot_seq_2,
                                                     True, pilot2file)
        self.PWF_pilot_gen_tx_0 = PWF.pilot_gen_tx(Nt, tlen, pilot_seq_1, True,
                                                   pilot1file)
        self.PWF_pilot_gen_rx_0_0 = PWF.pilot_gen_rx(Nt, tlen, prewhiten0,
                                                     pilot_seq_1, True,
                                                     pilot1file)
        self.PWF_pilot_gen_rx_0 = PWF.pilot_gen_rx(Nt, tlen, prewhiten1,
                                                   pilot_seq_2, True,
                                                   pilot2file)
        self.PWF_debug_printmsg_0 = PWF.debug_printmsg(L, Nt, False, 20)
        self.PWF_channel_1 = PWF.channel(L, Nt, ichn_gain_dB, channel, False,
                                         noise_hat, False, channelfile)
        self.PWF_channel_0 = PWF.channel(L, Nt, ichn_gain_dB, channel, True,
                                         noise, True, channelfile)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.PWF_channel_0, 0),
                     (self.blocks_vector_to_streams_1_1, 0))
        self.connect((self.PWF_channel_0, 1),
                     (self.blocks_vector_to_streams_1_1_0, 0))
        self.connect((self.PWF_channel_1, 1),
                     (self.blocks_vector_to_streams_1_1_0_0, 0))
        self.connect((self.PWF_channel_1, 0),
                     (self.blocks_vector_to_streams_1_1_1, 0))
        self.connect((self.PWF_debug_printmsg_0, 0),
                     (self.PWF_pilot_gen_tx_0, 0))
        self.connect((self.PWF_debug_printmsg_0, 1),
                     (self.PWF_pilot_gen_tx_0_0, 0))
        self.connect((self.PWF_pilot_gen_rx_0, 0),
                     (self.blocks_vector_to_streams_1_0_0, 0))
        self.connect((self.PWF_pilot_gen_rx_0_0, 0),
                     (self.blocks_vector_to_streams_1_2, 0))
        self.connect((self.PWF_pilot_gen_tx_0, 0),
                     (self.blocks_vector_to_streams_1, 0))
        self.connect((self.PWF_pilot_gen_tx_0_0, 0),
                     (self.blocks_vector_to_streams_1_0, 0))
        self.connect((self.PWF_pilot_receive_rx_0, 0),
                     (self.PWF_power_adjust_1, 0))
        self.connect((self.PWF_pilot_receive_rx_0_0, 0),
                     (self.PWF_power_adjust_1, 1))
        self.connect((self.PWF_pilot_receive_tx_0, 0),
                     (self.PWF_power_adjust_1_0, 1))
        self.connect((self.PWF_pilot_receive_tx_0_0, 0),
                     (self.PWF_power_adjust_1_0, 0))
        self.connect((self.PWF_power_adjust_1, 1),
                     (self.PWF_pilot_gen_rx_0, 0))
        self.connect((self.PWF_power_adjust_1, 0),
                     (self.PWF_pilot_gen_rx_0_0, 0))
        self.connect((self.PWF_power_adjust_1_0, 0),
                     (self.blocks_streams_to_vector_0_0, 0))
        self.connect((self.PWF_power_adjust_1_0, 1),
                     (self.blocks_streams_to_vector_0_0, 1))
        self.connect((self.PWF_sigmagen_0, 0),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.PWF_sigmagen_0, 1),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.PWF_weighted_sum_rate_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.PWF_weighted_sum_rate_0, 1),
                     (self.blocks_repeat_0_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_repeat_0_0, 0),
                     (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_streams_to_vector_0, 0),
                     (self.blocks_udp_sink_1, 0))
        self.connect((self.blocks_streams_to_vector_0_0, 0),
                     (self.blocks_udp_sink_1_0, 0))
        self.connect((self.blocks_streams_to_vector_1, 0),
                     (self.PWF_channel_0, 0))
        self.connect((self.blocks_streams_to_vector_1_0, 0),
                     (self.PWF_channel_0, 1))
        self.connect((self.blocks_streams_to_vector_1_0_0, 0),
                     (self.PWF_channel_1, 1))
        self.connect((self.blocks_streams_to_vector_1_1, 0),
                     (self.PWF_pilot_receive_rx_0, 0))
        self.connect((self.blocks_streams_to_vector_1_1_0, 0),
                     (self.PWF_pilot_receive_rx_0_0, 0))
        self.connect((self.blocks_streams_to_vector_1_1_0_0, 0),
                     (self.PWF_pilot_receive_tx_0, 0))
        self.connect((self.blocks_streams_to_vector_1_1_1, 0),
                     (self.PWF_pilot_receive_tx_0_0, 0))
        self.connect((self.blocks_streams_to_vector_1_2, 0),
                     (self.PWF_channel_1, 0))
        self.connect((self.blocks_udp_source_1, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_udp_source_1, 0),
                     (self.blocks_vector_to_streams_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 0),
                     (self.PWF_debug_printmsg_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 1),
                     (self.PWF_debug_printmsg_0, 1))
        self.connect((self.blocks_vector_to_streams_0, 0),
                     (self.PWF_weighted_sum_rate_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 1),
                     (self.PWF_weighted_sum_rate_0, 1))
        self.connect((self.blocks_vector_to_streams_1, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.blocks_vector_to_streams_1, 1),
                     (self.interp_fir_filter_xxx_0_1, 0))
        self.connect((self.blocks_vector_to_streams_1_0, 0),
                     (self.interp_fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_vector_to_streams_1_0, 1),
                     (self.interp_fir_filter_xxx_0_1_0, 0))
        self.connect((self.blocks_vector_to_streams_1_0_0, 0),
                     (self.blocks_streams_to_vector_1_0_0, 0))
        self.connect((self.blocks_vector_to_streams_1_0_0, 1),
                     (self.blocks_streams_to_vector_1_0_0, 1))
        self.connect((self.blocks_vector_to_streams_1_1, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_vector_to_streams_1_1, 1),
                     (self.fir_filter_xxx_0_0, 0))
        self.connect((self.blocks_vector_to_streams_1_1_0, 1),
                     (self.fir_filter_xxx_0_0_0, 0))
        self.connect((self.blocks_vector_to_streams_1_1_0, 0),
                     (self.fir_filter_xxx_0_1, 0))
        self.connect((self.blocks_vector_to_streams_1_1_0_0, 1),
                     (self.phase_corrector_0_0_0_0, 0))
        self.connect((self.blocks_vector_to_streams_1_1_0_0, 0),
                     (self.phase_corrector_0_1_0, 0))
        self.connect((self.blocks_vector_to_streams_1_1_1, 1),
                     (self.phase_corrector_0_0_1, 0))
        self.connect((self.blocks_vector_to_streams_1_1_1, 0),
                     (self.phase_corrector_0_2, 0))
        self.connect((self.blocks_vector_to_streams_1_2, 1),
                     (self.blocks_streams_to_vector_1_2, 1))
        self.connect((self.blocks_vector_to_streams_1_2, 0),
                     (self.blocks_streams_to_vector_1_2, 0))
        self.connect((self.fir_filter_xxx_0, 0), (self.phase_corrector_0, 0))
        self.connect((self.fir_filter_xxx_0_0, 0),
                     (self.phase_corrector_0_0, 0))
        self.connect((self.fir_filter_xxx_0_0_0, 0),
                     (self.phase_corrector_0_0_0, 0))
        self.connect((self.fir_filter_xxx_0_1, 0),
                     (self.phase_corrector_0_1, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0),
                     (self.blocks_streams_to_vector_1, 0))
        self.connect((self.interp_fir_filter_xxx_0_0, 0),
                     (self.blocks_streams_to_vector_1_0, 0))
        self.connect((self.interp_fir_filter_xxx_0_1, 0),
                     (self.blocks_streams_to_vector_1, 1))
        self.connect((self.interp_fir_filter_xxx_0_1_0, 0),
                     (self.blocks_streams_to_vector_1_0, 1))
        self.connect((self.phase_corrector_0, 0),
                     (self.blocks_streams_to_vector_1_1, 0))
        self.connect((self.phase_corrector_0_0, 0),
                     (self.blocks_streams_to_vector_1_1, 1))
        self.connect((self.phase_corrector_0_0_0, 0),
                     (self.blocks_streams_to_vector_1_1_0, 1))
        self.connect((self.phase_corrector_0_0_0_0, 0),
                     (self.blocks_streams_to_vector_1_1_0_0, 1))
        self.connect((self.phase_corrector_0_0_1, 0),
                     (self.blocks_streams_to_vector_1_1_1, 1))
        self.connect((self.phase_corrector_0_1, 0),
                     (self.blocks_streams_to_vector_1_1_0, 0))
        self.connect((self.phase_corrector_0_1_0, 0),
                     (self.blocks_streams_to_vector_1_1_0_0, 0))
        self.connect((self.phase_corrector_0_2, 0),
                     (self.blocks_streams_to_vector_1_1_1, 0))
コード例 #32
0
    def __init__(self):
        gr.top_block.__init__(self, "USRP to Vector ")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("USRP to Vector ")
        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", "vector_sink")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.variable_0 = variable_0 = 0
        self.samp_rate = samp_rate = int(2e6)
        self.goertzel_length = goertzel_length = 4096
        self.const = const = 2
        self.TX_freqs = TX_freqs = (1e5, 1.5e5, 2e5, 2.5e5, 3e5, 3.5e5, 4e5,
                                    4.5e5, 5e5, 5.5e5, 6e5, 6.5e5, 7e5, 7.5e5,
                                    8e5)

        ##################################################
        # Blocks
        ##################################################
        self.my_tabs = Qt.QTabWidget()
        self.my_tabs_widget_0 = Qt.QWidget()
        self.my_tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.my_tabs_widget_0)
        self.my_tabs_grid_layout_0 = Qt.QGridLayout()
        self.my_tabs_layout_0.addLayout(self.my_tabs_grid_layout_0)
        self.my_tabs.addTab(self.my_tabs_widget_0, "Tx 1-10")
        self.my_tabs_widget_1 = Qt.QWidget()
        self.my_tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.my_tabs_widget_1)
        self.my_tabs_grid_layout_1 = Qt.QGridLayout()
        self.my_tabs_layout_1.addLayout(self.my_tabs_grid_layout_1)
        self.my_tabs.addTab(self.my_tabs_widget_1, "Tx 11-15")
        self.my_tabs_widget_2 = Qt.QWidget()
        self.my_tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.my_tabs_widget_2)
        self.my_tabs_grid_layout_2 = Qt.QGridLayout()
        self.my_tabs_layout_2.addLayout(self.my_tabs_grid_layout_2)
        self.my_tabs.addTab(self.my_tabs_widget_2, "Freq Sink")
        self.top_layout.addWidget(self.my_tabs)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(0, 0)
        self.uhd_usrp_source_0_0.set_gain(0, 0)
        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.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)
        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.my_tabs_layout_2.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 5)
        self.qtgui_number_sink_1.set_update_time(0.10)
        self.qtgui_number_sink_1.set_title("")

        labels = [
            "Signal  11", "Signal  12", "Signal  13", "Signal  14",
            "Signal  15", "", "", "", "", ""
        ]
        units = ["", "", "", "", "", "", "", "", "", ""]
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(5):
            self.qtgui_number_sink_1.set_min(i, -1)
            self.qtgui_number_sink_1.set_max(i, 1)
            self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_1.set_label(i, labels[i])
            self.qtgui_number_sink_1.set_unit(i, units[i])
            self.qtgui_number_sink_1.set_factor(i, factor[i])

        self.qtgui_number_sink_1.enable_autoscale(False)
        self._qtgui_number_sink_1_win = sip.wrapinstance(
            self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget)
        self.my_tabs_layout_1.addWidget(self._qtgui_number_sink_1_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 10)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = [
            "Signal 1", "Signal  2", "Signal  3", "Signal  4", "Signal  5",
            " Signal 6", "Signal 7", "Signal 8", "Signal  9", "Signal 10"
        ]
        units = ["", "", "", "", "", "", "", "", "", ""]
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(10):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.my_tabs_layout_0.addWidget(self._qtgui_number_sink_0_win)
        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.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        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_control_panel(False)

        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 = ["", "", "", "", "", "", "", "", "", ""]
        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_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.my_tabs_layout_2.addWidget(self._qtgui_freq_sink_x_0_win)
        self.multi_goertzel_0 = multi_goertzel(
            freqs=TX_freqs,
            goertzel_size=goertzel_length,
            mult=const,
            samp_rate=samp_rate,
        )
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(
            gr.sizeof_float * 1, 15)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 15,
                                                   sys.argv[1], False)
        self.blocks_file_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_streams_to_vector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.multi_goertzel_0, 0),
                     (self.blocks_streams_to_vector_0, 0))
        self.connect((self.multi_goertzel_0, 1),
                     (self.blocks_streams_to_vector_0, 1))
        self.connect((self.multi_goertzel_0, 11),
                     (self.blocks_streams_to_vector_0, 11))
        self.connect((self.multi_goertzel_0, 12),
                     (self.blocks_streams_to_vector_0, 12))
        self.connect((self.multi_goertzel_0, 13),
                     (self.blocks_streams_to_vector_0, 13))
        self.connect((self.multi_goertzel_0, 14),
                     (self.blocks_streams_to_vector_0, 14))
        self.connect((self.multi_goertzel_0, 2),
                     (self.blocks_streams_to_vector_0, 2))
        self.connect((self.multi_goertzel_0, 3),
                     (self.blocks_streams_to_vector_0, 3))
        self.connect((self.multi_goertzel_0, 4),
                     (self.blocks_streams_to_vector_0, 4))
        self.connect((self.multi_goertzel_0, 5),
                     (self.blocks_streams_to_vector_0, 5))
        self.connect((self.multi_goertzel_0, 6),
                     (self.blocks_streams_to_vector_0, 6))
        self.connect((self.multi_goertzel_0, 7),
                     (self.blocks_streams_to_vector_0, 7))
        self.connect((self.multi_goertzel_0, 8),
                     (self.blocks_streams_to_vector_0, 8))
        self.connect((self.multi_goertzel_0, 9),
                     (self.blocks_streams_to_vector_0, 9))
        self.connect((self.multi_goertzel_0, 10),
                     (self.blocks_streams_to_vector_0, 10))
        self.connect((self.multi_goertzel_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.multi_goertzel_0, 1), (self.qtgui_number_sink_0, 1))
        self.connect((self.multi_goertzel_0, 2), (self.qtgui_number_sink_0, 2))
        self.connect((self.multi_goertzel_0, 3), (self.qtgui_number_sink_0, 3))
        self.connect((self.multi_goertzel_0, 4), (self.qtgui_number_sink_0, 4))
        self.connect((self.multi_goertzel_0, 5), (self.qtgui_number_sink_0, 5))
        self.connect((self.multi_goertzel_0, 6), (self.qtgui_number_sink_0, 6))
        self.connect((self.multi_goertzel_0, 7), (self.qtgui_number_sink_0, 7))
        self.connect((self.multi_goertzel_0, 8), (self.qtgui_number_sink_0, 8))
        self.connect((self.multi_goertzel_0, 9), (self.qtgui_number_sink_0, 9))
        self.connect((self.multi_goertzel_0, 11),
                     (self.qtgui_number_sink_1, 1))
        self.connect((self.multi_goertzel_0, 12),
                     (self.qtgui_number_sink_1, 2))
        self.connect((self.multi_goertzel_0, 13),
                     (self.qtgui_number_sink_1, 3))
        self.connect((self.multi_goertzel_0, 14),
                     (self.qtgui_number_sink_1, 4))
        self.connect((self.multi_goertzel_0, 10),
                     (self.qtgui_number_sink_1, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.multi_goertzel_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
コード例 #33
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 = 15e6
        self.if_bandwidth_1 = if_bandwidth_1 = 2e6
        self.sdr_gain = sdr_gain = 60
        self.integration_bandwidth = integration_bandwidth = 5e3
        self.if_filter_decimation_rate = if_filter_decimation_rate = int(samp_rate/(1.1*if_bandwidth_1))
        self.sdr_power_offset = sdr_power_offset = 1.0
        self.sdr_gain_lin = sdr_gain_lin = 10**(sdr_gain/20)
        self.num_channels = num_channels = int((samp_rate/if_filter_decimation_rate)/integration_bandwidth)
        self.lna_gain_measured = lna_gain_measured = 33.33
        self.integration_time = integration_time = 10
        self.if_samp_rate = if_samp_rate = samp_rate/if_filter_decimation_rate
        self.cable_loss = cable_loss = 0.25
        self.variable_function_probe = variable_function_probe = 0
        self.sdr_frequency = sdr_frequency = 1420.406e6
        self.output_vector_bandwidth = output_vector_bandwidth = samp_rate/if_filter_decimation_rate
        self.offset_frequency = offset_frequency = if_bandwidth_1/2+1e5
        self.integration_scale_factor = integration_scale_factor = np.full((num_channels),float(1.0/(integration_time*integration_bandwidth*50)),dtype=float)
        self.integration_dec_rate = integration_dec_rate = int(integration_time*if_samp_rate/num_channels)
        self.if_filter_gain = if_filter_gain = 1/(lna_gain_measured*cable_loss*sdr_gain_lin*sdr_power_offset)
        self.if_bandwidth_0 = if_bandwidth_0 = 5.5e6
        self.channel_skirt = channel_skirt = integration_bandwidth/100
        self.channel_map = channel_map = range(int(num_channels/2.0+1.0),num_channels,1)+range(0,int(num_channels/2.0+1.0),1)
        self.antenna_gain_estimated = antenna_gain_estimated = 173

        ##################################################
        # Blocks
        ##################################################
        self.probe_signal = blocks.probe_signal_vf(num_channels)
        
        def _variable_function_probe_probe():
            while True:
                val = self.probe_signal.level()
                try:
                    self.set_variable_function_probe(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _variable_function_probe_thread = threading.Thread(target=_variable_function_probe_probe)
        _variable_function_probe_thread.daemon = True
        _variable_function_probe_thread.start()
            
        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(
              num_channels,
              (firdes.low_pass(1, if_samp_rate, (integration_bandwidth/2-channel_skirt), channel_skirt, firdes.WIN_HAMMING)),
              1.0,
              0)
        self.pfb_channelizer_ccf_0.set_channel_map((channel_map))
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)
            
        self.low_pass_filter_1 = filter.fir_filter_ccf(if_filter_decimation_rate, firdes.low_pass(
            if_filter_gain, samp_rate, if_bandwidth_1/2, 1e5, firdes.WIN_HAMMING, 6.76))
        self.limesdr_source_2 = limesdr.source('0009060B00471B22',
                     2,
                     1,
                     0,
                     0,
                     '',
                     sdr_frequency-offset_frequency,
                     samp_rate,
                     0,
                     1,
                     15e6,
                     0,
                     10e6,
                     3,
                     2,
                     2,
                     1,
                     if_bandwidth_0,
                     1,
                     5e6,
                     1,
                     if_bandwidth_0,
                     0,
                     0,
                     sdr_gain,
                     30,
                     0,
                     0,
                     0,
                     0)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, num_channels)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((integration_scale_factor))
        self.blocks_integrate_xx_0_0 = blocks.integrate_ff(integration_dec_rate, num_channels)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/w1xm-admin/Documents/DSP/data_out/recieve_block_sink', False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_copy_0_0 = blocks.copy(gr.sizeof_gr_complex*1)
        self.blocks_copy_0_0.set_enabled(False)
        self.blocks_copy_0 = blocks.copy(gr.sizeof_gr_complex*1)
        self.blocks_copy_0.set_enabled(True)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(num_channels)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, -offset_frequency, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_1, 1))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_0_0, 0))    
        self.connect((self.blocks_copy_0, 0), (self.blocks_multiply_xx_1, 0))    
        self.connect((self.blocks_copy_0_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.probe_signal, 0))    
        self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_1, 0))    
        self.connect((self.blocks_streams_to_vector_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.limesdr_source_2, 0), (self.blocks_copy_0, 0))    
        self.connect((self.limesdr_source_2, 0), (self.blocks_copy_0_0, 0))    
        self.connect((self.low_pass_filter_1, 0), (self.pfb_channelizer_ccf_0, 0))    
        
        for i in range(num_channels):
            self.connect((self.pfb_channelizer_ccf_0, i), (self.blocks_streams_to_vector_0, i))
コード例 #34
0
    def __init__(self):
        gr.top_block.__init__(self, "Receive Single FM Station")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Receive Single FM Station")
        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", "rcv_single_fm")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.rf_rate = rf_rate = 20e6
        self.rf_frequency_h = rf_frequency_h = 88.5
        self.fm_taps = fm_taps = firdes.low_pass_2(32., rf_rate, 96e3, 25e3, 50)
        self.audio_rate = audio_rate = 44100
        self.taps_len = taps_len = fm_taps.__len__()
        self.rf_gain = rf_gain = 50
        self.rf_frequency = rf_frequency = 98.1e6
        self.fm_channel_rate = fm_channel_rate = audio_rate*5
        self.channel_number = channel_number = int(10*(rf_frequency_h-98)) /2if rf_frequency_h>=98 else 50 + int(10*(rf_frequency_h-88.1))/2

        ##################################################
        # Blocks
        ##################################################
        self._rf_rate_range = Range(100e3, 20e6, 200e3, 20e6, 200)
        self._rf_rate_win = RangeWidget(self._rf_rate_range, self.set_rf_rate, 'RF sample rate', "counter_slider", float)
        self.top_layout.addWidget(self._rf_rate_win)
        self._rf_gain_range = Range(0, 90, 1, 50, 200)
        self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, 'RF gain', "counter_slider", float)
        self.top_layout.addWidget(self._rf_gain_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(rf_rate)
        self.uhd_usrp_source_0.set_center_freq(rf_frequency, 0)
        self.uhd_usrp_source_0.set_gain(rf_gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self._rf_frequency_h_range = Range(88.0, 108.0, .2, 88.5, 200)
        self._rf_frequency_h_win = RangeWidget(self._rf_frequency_h_range, self.set_rf_frequency_h, 'RF Frequency', "counter_slider", float)
        self.top_layout.addWidget(self._rf_frequency_h_win)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=fm_channel_rate,
                decimation=int(200e3),
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	rf_frequency, #fc
        	rf_rate, #bw
        	"Received Spectrum", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)
        
        if not True:
          self.qtgui_waterfall_sink_x_0_0.disable_legend()
        
        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10)
        
        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win)
        self.pfb_channelizer_ccf_0 = pfb.channelizer_ccf(
        	  100,
        	  (fm_taps),
        	  1.0,
        	  100)
        self.pfb_channelizer_ccf_0.set_channel_map(([channel_number]))
        self.pfb_channelizer_ccf_0.declare_sample_delay(0)
        	
        self.channel_power_display = qtgui.vector_sink_f(
            1,
            0,
            1.0,
            "x-Axis",
            "y-Axis",
            "Power per FM Channel",
            1 # Number of inputs
        )
        self.channel_power_display.set_update_time(0.10)
        self.channel_power_display.set_y_axis(-140, 10)
        self.channel_power_display.enable_autoscale(False)
        self.channel_power_display.enable_grid(False)
        self.channel_power_display.set_x_axis_units("")
        self.channel_power_display.set_y_axis_units("")
        self.channel_power_display.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.channel_power_display.set_line_label(i, "Data {0}".format(i))
            else:
                self.channel_power_display.set_line_label(i, labels[i])
            self.channel_power_display.set_line_width(i, widths[i])
            self.channel_power_display.set_line_color(i, colors[i])
            self.channel_power_display.set_line_alpha(i, alphas[i])
        
        self._channel_power_display_win = sip.wrapinstance(self.channel_power_display.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._channel_power_display_win)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(gr.sizeof_float*1, 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_streams_to_vector_0, 0))    
        self.connect((self.blocks_streams_to_vector_0, 0), (self.channel_power_display, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 1), (self.blocks_null_sink_0, 0))    
        self.connect((self.pfb_channelizer_ccf_0, 2), (self.blocks_null_sink_0, 1))    
        self.connect((self.pfb_channelizer_ccf_0, 3), (self.blocks_null_sink_0, 2))    
        self.connect((self.pfb_channelizer_ccf_0, 4), (self.blocks_null_sink_0, 3))    
        self.connect((self.pfb_channelizer_ccf_0, 5), (self.blocks_null_sink_0, 4))    
        self.connect((self.pfb_channelizer_ccf_0, 6), (self.blocks_null_sink_0, 5))    
        self.connect((self.pfb_channelizer_ccf_0, 7), (self.blocks_null_sink_0, 6))    
        self.connect((self.pfb_channelizer_ccf_0, 8), (self.blocks_null_sink_0, 7))    
        self.connect((self.pfb_channelizer_ccf_0, 9), (self.blocks_null_sink_0, 8))    
        self.connect((self.pfb_channelizer_ccf_0, 10), (self.blocks_null_sink_0, 9))    
        self.connect((self.pfb_channelizer_ccf_0, 11), (self.blocks_null_sink_0, 10))    
        self.connect((self.pfb_channelizer_ccf_0, 12), (self.blocks_null_sink_0, 11))    
        self.connect((self.pfb_channelizer_ccf_0, 13), (self.blocks_null_sink_0, 12))    
        self.connect((self.pfb_channelizer_ccf_0, 14), (self.blocks_null_sink_0, 13))    
        self.connect((self.pfb_channelizer_ccf_0, 15), (self.blocks_null_sink_0, 14))    
        self.connect((self.pfb_channelizer_ccf_0, 16), (self.blocks_null_sink_0, 15))    
        self.connect((self.pfb_channelizer_ccf_0, 17), (self.blocks_null_sink_0, 16))    
        self.connect((self.pfb_channelizer_ccf_0, 18), (self.blocks_null_sink_0, 17))    
        self.connect((self.pfb_channelizer_ccf_0, 19), (self.blocks_null_sink_0, 18))    
        self.connect((self.pfb_channelizer_ccf_0, 20), (self.blocks_null_sink_0, 19))    
        self.connect((self.pfb_channelizer_ccf_0, 21), (self.blocks_null_sink_0, 20))    
        self.connect((self.pfb_channelizer_ccf_0, 22), (self.blocks_null_sink_0, 21))    
        self.connect((self.pfb_channelizer_ccf_0, 23), (self.blocks_null_sink_0, 22))    
        self.connect((self.pfb_channelizer_ccf_0, 24), (self.blocks_null_sink_0, 23))    
        self.connect((self.pfb_channelizer_ccf_0, 25), (self.blocks_null_sink_0, 24))    
        self.connect((self.pfb_channelizer_ccf_0, 26), (self.blocks_null_sink_0, 25))    
        self.connect((self.pfb_channelizer_ccf_0, 27), (self.blocks_null_sink_0, 26))    
        self.connect((self.pfb_channelizer_ccf_0, 28), (self.blocks_null_sink_0, 27))    
        self.connect((self.pfb_channelizer_ccf_0, 29), (self.blocks_null_sink_0, 28))    
        self.connect((self.pfb_channelizer_ccf_0, 30), (self.blocks_null_sink_0, 29))    
        self.connect((self.pfb_channelizer_ccf_0, 31), (self.blocks_null_sink_0, 30))    
        self.connect((self.pfb_channelizer_ccf_0, 32), (self.blocks_null_sink_0, 31))    
        self.connect((self.pfb_channelizer_ccf_0, 33), (self.blocks_null_sink_0, 32))    
        self.connect((self.pfb_channelizer_ccf_0, 34), (self.blocks_null_sink_0, 33))    
        self.connect((self.pfb_channelizer_ccf_0, 35), (self.blocks_null_sink_0, 34))    
        self.connect((self.pfb_channelizer_ccf_0, 36), (self.blocks_null_sink_0, 35))    
        self.connect((self.pfb_channelizer_ccf_0, 37), (self.blocks_null_sink_0, 36))    
        self.connect((self.pfb_channelizer_ccf_0, 38), (self.blocks_null_sink_0, 37))    
        self.connect((self.pfb_channelizer_ccf_0, 39), (self.blocks_null_sink_0, 38))    
        self.connect((self.pfb_channelizer_ccf_0, 40), (self.blocks_null_sink_0, 39))    
        self.connect((self.pfb_channelizer_ccf_0, 41), (self.blocks_null_sink_0, 40))    
        self.connect((self.pfb_channelizer_ccf_0, 42), (self.blocks_null_sink_0, 41))    
        self.connect((self.pfb_channelizer_ccf_0, 43), (self.blocks_null_sink_0, 42))    
        self.connect((self.pfb_channelizer_ccf_0, 44), (self.blocks_null_sink_0, 43))    
        self.connect((self.pfb_channelizer_ccf_0, 45), (self.blocks_null_sink_0, 44))    
        self.connect((self.pfb_channelizer_ccf_0, 46), (self.blocks_null_sink_0, 45))    
        self.connect((self.pfb_channelizer_ccf_0, 47), (self.blocks_null_sink_0, 46))    
        self.connect((self.pfb_channelizer_ccf_0, 48), (self.blocks_null_sink_0, 47))    
        self.connect((self.pfb_channelizer_ccf_0, 49), (self.blocks_null_sink_0, 48))    
        self.connect((self.pfb_channelizer_ccf_0, 50), (self.blocks_null_sink_0, 49))    
        self.connect((self.pfb_channelizer_ccf_0, 51), (self.blocks_null_sink_0, 50))    
        self.connect((self.pfb_channelizer_ccf_0, 52), (self.blocks_null_sink_0, 51))    
        self.connect((self.pfb_channelizer_ccf_0, 53), (self.blocks_null_sink_0, 52))    
        self.connect((self.pfb_channelizer_ccf_0, 54), (self.blocks_null_sink_0, 53))    
        self.connect((self.pfb_channelizer_ccf_0, 55), (self.blocks_null_sink_0, 54))    
        self.connect((self.pfb_channelizer_ccf_0, 56), (self.blocks_null_sink_0, 55))    
        self.connect((self.pfb_channelizer_ccf_0, 57), (self.blocks_null_sink_0, 56))    
        self.connect((self.pfb_channelizer_ccf_0, 58), (self.blocks_null_sink_0, 57))    
        self.connect((self.pfb_channelizer_ccf_0, 59), (self.blocks_null_sink_0, 58))    
        self.connect((self.pfb_channelizer_ccf_0, 60), (self.blocks_null_sink_0, 59))    
        self.connect((self.pfb_channelizer_ccf_0, 61), (self.blocks_null_sink_0, 60))    
        self.connect((self.pfb_channelizer_ccf_0, 62), (self.blocks_null_sink_0, 61))    
        self.connect((self.pfb_channelizer_ccf_0, 63), (self.blocks_null_sink_0, 62))    
        self.connect((self.pfb_channelizer_ccf_0, 64), (self.blocks_null_sink_0, 63))    
        self.connect((self.pfb_channelizer_ccf_0, 65), (self.blocks_null_sink_0, 64))    
        self.connect((self.pfb_channelizer_ccf_0, 66), (self.blocks_null_sink_0, 65))    
        self.connect((self.pfb_channelizer_ccf_0, 67), (self.blocks_null_sink_0, 66))    
        self.connect((self.pfb_channelizer_ccf_0, 68), (self.blocks_null_sink_0, 67))    
        self.connect((self.pfb_channelizer_ccf_0, 69), (self.blocks_null_sink_0, 68))    
        self.connect((self.pfb_channelizer_ccf_0, 70), (self.blocks_null_sink_0, 69))    
        self.connect((self.pfb_channelizer_ccf_0, 71), (self.blocks_null_sink_0, 70))    
        self.connect((self.pfb_channelizer_ccf_0, 72), (self.blocks_null_sink_0, 71))    
        self.connect((self.pfb_channelizer_ccf_0, 73), (self.blocks_null_sink_0, 72))    
        self.connect((self.pfb_channelizer_ccf_0, 74), (self.blocks_null_sink_0, 73))    
        self.connect((self.pfb_channelizer_ccf_0, 75), (self.blocks_null_sink_0, 74))    
        self.connect((self.pfb_channelizer_ccf_0, 76), (self.blocks_null_sink_0, 75))    
        self.connect((self.pfb_channelizer_ccf_0, 77), (self.blocks_null_sink_0, 76))    
        self.connect((self.pfb_channelizer_ccf_0, 78), (self.blocks_null_sink_0, 77))    
        self.connect((self.pfb_channelizer_ccf_0, 79), (self.blocks_null_sink_0, 78))    
        self.connect((self.pfb_channelizer_ccf_0, 80), (self.blocks_null_sink_0, 79))    
        self.connect((self.pfb_channelizer_ccf_0, 81), (self.blocks_null_sink_0, 80))    
        self.connect((self.pfb_channelizer_ccf_0, 82), (self.blocks_null_sink_0, 81))    
        self.connect((self.pfb_channelizer_ccf_0, 83), (self.blocks_null_sink_0, 82))    
        self.connect((self.pfb_channelizer_ccf_0, 84), (self.blocks_null_sink_0, 83))    
        self.connect((self.pfb_channelizer_ccf_0, 85), (self.blocks_null_sink_0, 84))    
        self.connect((self.pfb_channelizer_ccf_0, 86), (self.blocks_null_sink_0, 85))    
        self.connect((self.pfb_channelizer_ccf_0, 87), (self.blocks_null_sink_0, 86))    
        self.connect((self.pfb_channelizer_ccf_0, 88), (self.blocks_null_sink_0, 87))    
        self.connect((self.pfb_channelizer_ccf_0, 89), (self.blocks_null_sink_0, 88))    
        self.connect((self.pfb_channelizer_ccf_0, 90), (self.blocks_null_sink_0, 89))    
        self.connect((self.pfb_channelizer_ccf_0, 91), (self.blocks_null_sink_0, 90))    
        self.connect((self.pfb_channelizer_ccf_0, 92), (self.blocks_null_sink_0, 91))    
        self.connect((self.pfb_channelizer_ccf_0, 93), (self.blocks_null_sink_0, 92))    
        self.connect((self.pfb_channelizer_ccf_0, 94), (self.blocks_null_sink_0, 93))    
        self.connect((self.pfb_channelizer_ccf_0, 95), (self.blocks_null_sink_0, 94))    
        self.connect((self.pfb_channelizer_ccf_0, 96), (self.blocks_null_sink_0, 95))    
        self.connect((self.pfb_channelizer_ccf_0, 97), (self.blocks_null_sink_0, 96))    
        self.connect((self.pfb_channelizer_ccf_0, 98), (self.blocks_null_sink_0, 97))    
        self.connect((self.pfb_channelizer_ccf_0, 99), (self.blocks_null_sink_0, 98))    
        self.connect((self.pfb_channelizer_ccf_0, 0), (self.rational_resampler_xxx_0, 0))    
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.pfb_channelizer_ccf_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))    
コード例 #35
0
    def __init__(self):
        gr.top_block.__init__(self, "MIMO TOP FLOW")

        ##################################################
        # Variables
        ##################################################
        self.fftl = fftl = 128
        self.samp_rate = samp_rate = fftl * 15e3
        self.rxant = rxant = 2
        self.resampler = resampler = 400
        self.frame_key = frame_key = "slot"
        self.N_rb_dl = N_rb_dl = 50

        ##################################################
        # Blocks
        ##################################################
        self.lte_mimo_sss_sync_0 = lte_mimo_sss_sync(
            N_rb_dl=N_rb_dl,
            rxant=rxant,
        )
        self.lte_mimo_pss_sync_0 = lte_mimo_pss_sync(
            rxant=rxant,
            synclen=5,
            fftlen=fftl,
        )
        self.lte_mimo_pss_based_frey_sync_0 = lte_mimo_pss_based_frey_sync(
            fftlen=fftl,
            rxant=rxant,
        )
        self.lte_mimo_ofdm_rx_0 = lte_mimo_ofdm_rx(
            N_rb_dl=N_rb_dl,
            ofdm_key=frame_key,
            fftlen=fftl,
            rxant=rxant,
        )
        self.lte_mimo_estimator_0 = lte_mimo_estimator(
            N_rb_dl=N_rb_dl,
            estimator_key=frame_key,
            initial_id=2,
            rxant=rxant,
        )
        self.lte_mimo_decode_pbch_0 = lte_mimo_decode_pbch(
            N_rb_dl=N_rb_dl,
            rxant=rxant,
        )
        self.blocks_vector_to_streams_0 = blocks.vector_to_streams(
            gr.sizeof_gr_complex * 1, 2)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 2,
                                                 samp_rate, True)
        self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(
            gr.sizeof_gr_complex * 12 * N_rb_dl, 2)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 2,
            "/home/johannes/src/gr-lte/tests/lte_test_data_RX2_NRBDL6.dat",
            True)
        self.bch_decode_bch_hier_gr37_0 = decode_bch_hier_gr37()
        self.MIB = lte.mib_unpack_vbm("MIB")

        ##################################################
        # Connections
        ##################################################
        self.connect((self.lte_mimo_pss_sync_0, 1),
                     (self.lte_mimo_pss_based_frey_sync_0, 1))
        self.connect((self.lte_mimo_pss_sync_0, 0),
                     (self.lte_mimo_pss_based_frey_sync_0, 0))
        self.connect((self.lte_mimo_pss_based_frey_sync_0, 0),
                     (self.lte_mimo_ofdm_rx_0, 0))
        self.connect((self.lte_mimo_pss_based_frey_sync_0, 1),
                     (self.lte_mimo_ofdm_rx_0, 1))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_vector_to_streams_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 0),
                     (self.lte_mimo_pss_sync_0, 0))
        self.connect((self.blocks_vector_to_streams_0, 1),
                     (self.lte_mimo_pss_sync_0, 1))
        self.connect((self.lte_mimo_ofdm_rx_0, 0),
                     (self.lte_mimo_sss_sync_0, 0))
        self.connect((self.lte_mimo_ofdm_rx_0, 1),
                     (self.lte_mimo_sss_sync_0, 1))
        self.connect((self.lte_mimo_decode_pbch_0, 0),
                     (self.bch_decode_bch_hier_gr37_0, 0))
        self.connect((self.lte_mimo_estimator_0, 0),
                     (self.lte_mimo_decode_pbch_0, 1))
        self.connect((self.lte_mimo_estimator_0, 1),
                     (self.lte_mimo_decode_pbch_0, 2))
        self.connect((self.bch_decode_bch_hier_gr37_0, 1), (self.MIB, 1))
        self.connect((self.bch_decode_bch_hier_gr37_0, 0), (self.MIB, 0))
        self.connect((self.lte_mimo_sss_sync_0, 1),
                     (self.blocks_streams_to_vector_0_0, 1))
        self.connect((self.lte_mimo_sss_sync_0, 0),
                     (self.blocks_streams_to_vector_0_0, 0))
        self.connect((self.blocks_streams_to_vector_0_0, 0),
                     (self.lte_mimo_estimator_0, 0))
        self.connect((self.blocks_streams_to_vector_0_0, 0),
                     (self.lte_mimo_decode_pbch_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.lte_mimo_sss_sync_0, "cell_id",
                         self.lte_mimo_estimator_0, "cell_id")
        self.msg_connect(self.lte_mimo_pss_sync_0, "N_id_2",
                         self.lte_mimo_sss_sync_0, "N_id_2")
        self.msg_connect(self.lte_mimo_sss_sync_0, "cell_id",
                         self.lte_mimo_decode_pbch_0, "cell_id")
コード例 #36
0
ファイル: top_block.py プロジェクト: Chris0718/gr-PWF
    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.Nt = Nt = 2
        self.dft_coef = dft_coef = np.exp(-2*np.pi*1j/Nt)
        self.A = A = np.arange(Nt)[np.newaxis]
        self.tlen = tlen = 4000
        self.samp_rate = samp_rate = 100000
        self.dft_matrix = dft_matrix = np.power(dft_coef, np.dot(A.transpose(),A))
        self.scramble_2 = scramble_2 = 2*np.random.random_integers(0,1,size=(tlen,Nt))-1
        self.scramble_1 = scramble_1 = 2*np.random.random_integers(0,1,size=(tlen,Nt))-1
        self.prefix = prefix = '/home/zhe/gr-PWF/examples'
        self.noise = noise = [np.identity(Nt), np.identity(Nt)]
        self.max_iteration = max_iteration = 20
        self.interpo = interpo = samp_rate/1000
        self.dft_pilot_seq = dft_pilot_seq = np.tile(dft_matrix,(tlen/Nt,1))
        self.Q = Q = 4
        self.L = L = 2
        self.sigmagenfile = sigmagenfile = prefix+'/sigmagens/sigmagen_10.bin'
        self.pulse = pulse = filter.firdes.root_raised_cosine(Q,Q,1,0.35,11*Q)
        self.prewhiten1 = prewhiten1 = np.linalg.pinv(noise[1])
        self.prewhiten0 = prewhiten0 = np.linalg.pinv(noise[0])
        self.pilot_seq_2 = pilot_seq_2 = np.multiply(dft_pilot_seq,scramble_2)
        self.pilot_seq_1 = pilot_seq_1 = np.multiply(dft_pilot_seq,scramble_1)
        self.pilot2file = pilot2file = prefix+'/pilots/pilot2_4000.bin'
        self.pilot1file = pilot1file = prefix+'/pilots/pilot1_4000.bin'
        self.payload_size = payload_size = 0
        self.npoints = npoints = max_iteration*interpo
        self.noise_hat = noise_hat = [np.identity(Nt), np.identity(Nt)]
        self.ichn_gain_dB = ichn_gain_dB = 10
        self.channelfile = channelfile = prefix+'/channels/2x2channel_10dB_3.bin'
        self.channel = channel = np.true_divide(np.random.standard_normal(size=(L,L,Nt,Nt))+np.random.standard_normal(size=(L,L,Nt,Nt))*1j,np.sqrt(2))
        self.Pt = Pt = 100

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	npoints, #size
        	samp_rate, #samp_rate
        	"Strong Interference (ichn_gain = 10dB)", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.1)
        self.qtgui_time_sink_x_0.set_y_axis(0, 20)
        
        self.qtgui_time_sink_x_0.set_y_label("Weighted Sum-Rate (bits/s/Hz)", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, 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_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["Dual Link", "Identity Sigma", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.phase_corrector_0_2 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_1[:,0],
        )
        self.phase_corrector_0_1_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_2[:,0],
        )
        self.phase_corrector_0_1 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_2[:,0],
        )
        self.phase_corrector_0_0_1 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_1[:,1],
        )
        self.phase_corrector_0_0_0_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_2[:,1],
        )
        self.phase_corrector_0_0_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_2[:,1],
        )
        self.phase_corrector_0_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_1[:,1],
        )
        self.phase_corrector_0 = phase_corrector(
            loop_bandwidth=2*np.pi*0.005,
            max_freq=2*np.pi*0.01,
            training_sequence=pilot_seq_1[:,0],
        )
        self.interp_fir_filter_xxx_0_1_0 = filter.interp_fir_filter_ccc(Q, (pulse))
        self.interp_fir_filter_xxx_0_1_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_1 = filter.interp_fir_filter_ccc(Q, (pulse))
        self.interp_fir_filter_xxx_0_1.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(Q, (pulse))
        self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(Q, (pulse))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_1 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0_0 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(Q, (pulse))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.blocks_vector_to_streams_1_2 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_1_1 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_1_0_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_1_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_1 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_0_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_1 = blocks.vector_to_streams(gr.sizeof_gr_complex*1, 2)
        self.blocks_vector_to_streams_0 = blocks.vector_to_streams(gr.sizeof_gr_complex*4, 2)
        self.blocks_udp_source_1 = blocks.udp_source(gr.sizeof_gr_complex*8, "127.0.0.1", 1234, 1472, True)
        self.blocks_udp_sink_1_0 = blocks.udp_sink(gr.sizeof_gr_complex*8, "127.0.0.1", 1234, 1472, True)
        self.blocks_udp_sink_1 = blocks.udp_sink(gr.sizeof_gr_complex*8, "127.0.0.1", 1234, 1472, True)
        self.blocks_streams_to_vector_1_2 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_1_1 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_1_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_1_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_1 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_1 = blocks.streams_to_vector(gr.sizeof_gr_complex*1, 2)
        self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*4, 2)
        self.blocks_streams_to_vector_0 = blocks.streams_to_vector(gr.sizeof_gr_complex*4, 2)
        self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_float*1, interpo)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, interpo)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*8, "/home/zhe/Dropbox/gnuradio_trunk/gnufiles/udp", False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.PWF_weighted_sum_rate_0 = PWF.weighted_sum_rate(L, Nt, Pt, channel, ichn_gain_dB, [1,1],[prewhiten0 ,prewhiten1], False, channelfile)
        self.PWF_sigmagen_0 = PWF.sigmagen(L, Nt, Pt, True, sigmagenfile)
        self.PWF_power_adjust_1_0 = PWF.power_adjust(Nt, Pt, L)
        self.PWF_power_adjust_1 = PWF.power_adjust(Nt, Pt, L)
        self.PWF_pilot_receive_tx_0_0 = PWF.pilot_receive_tx(True, pilot1file, pilot_seq_1, Nt, tlen,noise_hat[0], tlen, 1)
        self.PWF_pilot_receive_tx_0 = PWF.pilot_receive_tx(True, pilot2file, pilot_seq_2, Nt, tlen,noise_hat[1], tlen, 1)
        self.PWF_pilot_receive_rx_0_0 = PWF.pilot_receive_rx(True, pilot2file, pilot_seq_2, prewhiten1, Nt, tlen, tlen+payload_size, 1)
        self.PWF_pilot_receive_rx_0 = PWF.pilot_receive_rx(True, pilot1file, pilot_seq_1, prewhiten0, Nt, tlen, tlen+payload_size, 1)
        self.PWF_pilot_gen_tx_0_0 = PWF.pilot_gen_tx(Nt, tlen, pilot_seq_2, True, pilot2file)
        self.PWF_pilot_gen_tx_0 = PWF.pilot_gen_tx(Nt, tlen, pilot_seq_1, True, pilot1file)
        self.PWF_pilot_gen_rx_0_0 = PWF.pilot_gen_rx(Nt, tlen, prewhiten0, pilot_seq_1, True, pilot1file)
        self.PWF_pilot_gen_rx_0 = PWF.pilot_gen_rx(Nt, tlen, prewhiten1, pilot_seq_2, True, pilot2file)
        self.PWF_debug_printmsg_0 = PWF.debug_printmsg(L, Nt, False, 20)
        self.PWF_channel_1 = PWF.channel(L, Nt, ichn_gain_dB, channel, False,noise_hat, False, channelfile)
        self.PWF_channel_0 = PWF.channel(L, Nt, ichn_gain_dB, channel, True,noise, True, channelfile)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.PWF_channel_0, 0), (self.blocks_vector_to_streams_1_1, 0))    
        self.connect((self.PWF_channel_0, 1), (self.blocks_vector_to_streams_1_1_0, 0))    
        self.connect((self.PWF_channel_1, 1), (self.blocks_vector_to_streams_1_1_0_0, 0))    
        self.connect((self.PWF_channel_1, 0), (self.blocks_vector_to_streams_1_1_1, 0))    
        self.connect((self.PWF_debug_printmsg_0, 0), (self.PWF_pilot_gen_tx_0, 0))    
        self.connect((self.PWF_debug_printmsg_0, 1), (self.PWF_pilot_gen_tx_0_0, 0))    
        self.connect((self.PWF_pilot_gen_rx_0, 0), (self.blocks_vector_to_streams_1_0_0, 0))    
        self.connect((self.PWF_pilot_gen_rx_0_0, 0), (self.blocks_vector_to_streams_1_2, 0))    
        self.connect((self.PWF_pilot_gen_tx_0, 0), (self.blocks_vector_to_streams_1, 0))    
        self.connect((self.PWF_pilot_gen_tx_0_0, 0), (self.blocks_vector_to_streams_1_0, 0))    
        self.connect((self.PWF_pilot_receive_rx_0, 0), (self.PWF_power_adjust_1, 0))    
        self.connect((self.PWF_pilot_receive_rx_0_0, 0), (self.PWF_power_adjust_1, 1))    
        self.connect((self.PWF_pilot_receive_tx_0, 0), (self.PWF_power_adjust_1_0, 1))    
        self.connect((self.PWF_pilot_receive_tx_0_0, 0), (self.PWF_power_adjust_1_0, 0))    
        self.connect((self.PWF_power_adjust_1, 1), (self.PWF_pilot_gen_rx_0, 0))    
        self.connect((self.PWF_power_adjust_1, 0), (self.PWF_pilot_gen_rx_0_0, 0))    
        self.connect((self.PWF_power_adjust_1_0, 0), (self.blocks_streams_to_vector_0_0, 0))    
        self.connect((self.PWF_power_adjust_1_0, 1), (self.blocks_streams_to_vector_0_0, 1))    
        self.connect((self.PWF_sigmagen_0, 0), (self.blocks_streams_to_vector_0, 0))    
        self.connect((self.PWF_sigmagen_0, 1), (self.blocks_streams_to_vector_0, 1))    
        self.connect((self.PWF_weighted_sum_rate_0, 0), (self.blocks_repeat_0, 0))    
        self.connect((self.PWF_weighted_sum_rate_0, 1), (self.blocks_repeat_0_0, 0))    
        self.connect((self.blocks_repeat_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_repeat_0_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.blocks_streams_to_vector_0, 0), (self.blocks_udp_sink_1, 0))    
        self.connect((self.blocks_streams_to_vector_0_0, 0), (self.blocks_udp_sink_1_0, 0))    
        self.connect((self.blocks_streams_to_vector_1, 0), (self.PWF_channel_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_0, 0), (self.PWF_channel_0, 1))    
        self.connect((self.blocks_streams_to_vector_1_0_0, 0), (self.PWF_channel_1, 1))    
        self.connect((self.blocks_streams_to_vector_1_1, 0), (self.PWF_pilot_receive_rx_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_1_0, 0), (self.PWF_pilot_receive_rx_0_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_1_0_0, 0), (self.PWF_pilot_receive_tx_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_1_1, 0), (self.PWF_pilot_receive_tx_0_0, 0))    
        self.connect((self.blocks_streams_to_vector_1_2, 0), (self.PWF_channel_1, 0))    
        self.connect((self.blocks_udp_source_1, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_udp_source_1, 0), (self.blocks_vector_to_streams_0, 0))    
        self.connect((self.blocks_vector_to_streams_0, 0), (self.PWF_debug_printmsg_0, 0))    
        self.connect((self.blocks_vector_to_streams_0, 1), (self.PWF_debug_printmsg_0, 1))    
        self.connect((self.blocks_vector_to_streams_0, 0), (self.PWF_weighted_sum_rate_0, 0))    
        self.connect((self.blocks_vector_to_streams_0, 1), (self.PWF_weighted_sum_rate_0, 1))    
        self.connect((self.blocks_vector_to_streams_1, 0), (self.interp_fir_filter_xxx_0, 0))    
        self.connect((self.blocks_vector_to_streams_1, 1), (self.interp_fir_filter_xxx_0_1, 0))    
        self.connect((self.blocks_vector_to_streams_1_0, 0), (self.interp_fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_0, 1), (self.interp_fir_filter_xxx_0_1_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_0_0, 0), (self.blocks_streams_to_vector_1_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_0_0, 1), (self.blocks_streams_to_vector_1_0_0, 1))    
        self.connect((self.blocks_vector_to_streams_1_1, 0), (self.fir_filter_xxx_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1, 1), (self.fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_0, 1), (self.fir_filter_xxx_0_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_0, 0), (self.fir_filter_xxx_0_1, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_0_0, 1), (self.phase_corrector_0_0_0_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_0_0, 0), (self.phase_corrector_0_1_0, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_1, 1), (self.phase_corrector_0_0_1, 0))    
        self.connect((self.blocks_vector_to_streams_1_1_1, 0), (self.phase_corrector_0_2, 0))    
        self.connect((self.blocks_vector_to_streams_1_2, 1), (self.blocks_streams_to_vector_1_2, 1))    
        self.connect((self.blocks_vector_to_streams_1_2, 0), (self.blocks_streams_to_vector_1_2, 0))    
        self.connect((self.fir_filter_xxx_0, 0), (self.phase_corrector_0, 0))    
        self.connect((self.fir_filter_xxx_0_0, 0), (self.phase_corrector_0_0, 0))    
        self.connect((self.fir_filter_xxx_0_0_0, 0), (self.phase_corrector_0_0_0, 0))    
        self.connect((self.fir_filter_xxx_0_1, 0), (self.phase_corrector_0_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_streams_to_vector_1, 0))    
        self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_streams_to_vector_1_0, 0))    
        self.connect((self.interp_fir_filter_xxx_0_1, 0), (self.blocks_streams_to_vector_1, 1))    
        self.connect((self.interp_fir_filter_xxx_0_1_0, 0), (self.blocks_streams_to_vector_1_0, 1))    
        self.connect((self.phase_corrector_0, 0), (self.blocks_streams_to_vector_1_1, 0))    
        self.connect((self.phase_corrector_0_0, 0), (self.blocks_streams_to_vector_1_1, 1))    
        self.connect((self.phase_corrector_0_0_0, 0), (self.blocks_streams_to_vector_1_1_0, 1))    
        self.connect((self.phase_corrector_0_0_0_0, 0), (self.blocks_streams_to_vector_1_1_0_0, 1))    
        self.connect((self.phase_corrector_0_0_1, 0), (self.blocks_streams_to_vector_1_1_1, 1))    
        self.connect((self.phase_corrector_0_1, 0), (self.blocks_streams_to_vector_1_1_0, 0))    
        self.connect((self.phase_corrector_0_1_0, 0), (self.blocks_streams_to_vector_1_1_0_0, 0))    
        self.connect((self.phase_corrector_0_2, 0), (self.blocks_streams_to_vector_1_1_1, 0))    
コード例 #37
0
ファイル: filterbank.py プロジェクト: 0x7678/gnuradio-wg-grc
    def __init__(self, mpoints, taps=None):
        """
        Takes M complex streams in, produces single complex stream out
        that runs at M times the input sample rate

        Args:
            mpoints: number of freq bins/interpolation factor/subbands
            taps: filter taps for subband filter

        The channel spacing is equal to the input sample rate.
        The total bandwidth and output sample rate are equal the input
        sample rate * nchannels.

        Output stream to frequency mapping:

          channel zero is at zero frequency.

          if mpoints is odd:

            Channels with increasing positive frequencies come from
            channels 1 through (N-1)/2.

            Channel (N+1)/2 is the maximum negative frequency, and
            frequency increases through N-1 which is one channel lower
            than the zero frequency.

          if mpoints is even:

            Channels with increasing positive frequencies come from
            channels 1 through (N/2)-1.

            Channel (N/2) is evenly split between the max positive and
            negative bins.

            Channel (N/2)+1 is the maximum negative frequency, and
            frequency increases through N-1 which is one channel lower
            than the zero frequency.

            Channels near the frequency extremes end up getting cut
            off by subsequent filters and therefore have diminished
            utility.
        """
        item_size = gr.sizeof_gr_complex
        gr.hier_block2.__init__(self, "synthesis_filterbank",
                                gr.io_signature(mpoints, mpoints, item_size), # Input signature
                                gr.io_signature(1, 1, item_size))             # Output signature


        if taps is None:
            taps = _generate_synthesis_taps(mpoints)

        # pad taps to multiple of mpoints
        r = len(taps) % mpoints
        if r != 0:
            taps = taps + (mpoints - r) * (0,)

        # split in mpoints separate set of taps
        sub_taps = _split_taps(taps, mpoints)

        self.ss2v = blocks.streams_to_vector(item_size, mpoints)
        self.ifft = fft.fft_vcc(mpoints, False, [])
        self.v2ss = blocks.vector_to_streams(item_size, mpoints)
        # mpoints filters go in here...
        self.ss2s = blocks.streams_to_stream(item_size, mpoints)

        for i in range(mpoints):
            self.connect((self, i), (self.ss2v, i))

        self.connect(self.ss2v, self.ifft, self.v2ss)

        # build mpoints fir filters...
        for i in range(mpoints):
            f = fft_filter_ccc(1, sub_taps[i])
            self.connect((self.v2ss, i), f)
            self.connect(f, (self.ss2s, i))

	self.connect(self.ss2s, self)
コード例 #38
0
    def __init__(self):
        parser = ArgumentParser()
        parser.add_argument("-i",
                            "--ifile",
                            dest="ifilename",
                            help="read from FILE",
                            metavar="FILE",
                            required=True)
        parser.add_argument("-o",
                            "--ofile",
                            dest="ofilename",
                            help="write to FILE",
                            metavar="FILE",
                            required=True)
        args = parser.parse_args()
        print("Reading from file {}".format(args.ifilename))
        print("Writing to file {}".format(args.ofilename))

        gr.top_block.__init__(self, "Not titled yet")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Not titled yet")
        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", "somfy_receiver")

        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.zeta = zeta = 1.0
        self.ted_gain = ted_gain = 1
        self.samp_rate = samp_rate = 2.4e6
        self.samp_per_sym = samp_per_sym = 5
        self.omega_n_norm = omega_n_norm = 0.045
        self.ofile = ofile = args.ofilename
        self.ifile = ifile = args.ifilename
        self.fmid = fmid = 868.949e6
        self.dfctr3 = dfctr3 = 0
        self.dfctr2 = dfctr2 = -19.2e3
        self.dfctr1 = dfctr1 = 19.2e3
        self.baud_rate = baud_rate = 4800 * 4

        ##################################################
        # Blocks
        ##################################################
        self._zeta_range = Range(0.1, 5.0, 0.1, 1.0, 200)
        self._zeta_win = RangeWidget(self._zeta_range, self.set_zeta,
                                     'Damping Factor', "counter_slider", float)
        self.top_grid_layout.addWidget(self._zeta_win, 0, 0, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._ted_gain_range = Range(0.05, 5.0, 0.01, 1, 200)
        self._ted_gain_win = RangeWidget(self._ted_gain_range,
                                         self.set_ted_gain,
                                         'Expected TED Gain', "counter_slider",
                                         float)
        self.top_grid_layout.addWidget(self._ted_gain_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._omega_n_norm_range = Range(0.0, 2.0 * math.pi * 0.25, 0.001,
                                         0.045, 200)
        self._omega_n_norm_win = RangeWidget(self._omega_n_norm_range,
                                             self.set_omega_n_norm,
                                             'Normalized Bandwidth',
                                             "counter_slider", float)
        self.top_grid_layout.addWidget(self._omega_n_norm_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_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f(
            256,  #size
            baud_rate,  #samp_rate
            'Symbol Synced Output and Debug',  #name
            4  #number of inputs
        )
        self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(0.1)
        self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1.5, samp_per_sym + 2)

        self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode(
            qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.1, 0.01, 0,
            "time_est")
        self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False)

        labels = [
            'Soft Bits', 'Error', 'Instantaneous Period', 'Average Period', '',
            '', '', '', '', ''
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow',
            'dark red', 'dark green', 'dark blue'
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1]

        for i in range(4):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win,
                                       3, 1, 1, 2)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            3)
        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(False)
        self.qtgui_freq_sink_x_1.enable_grid(False)
        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)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(3):
            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, 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)
        self.fir_filter_xxx_0_1_0_0_0_0_0 = filter.fir_filter_fff(
            1, [1.0 / float(samp_per_sym)] * samp_per_sym)
        self.fir_filter_xxx_0_1_0_0_0_0_0.declare_sample_delay(
            int((samp_per_sym - 1.0) / 2.0) + 4)
        self.fir_filter_xxx_0_1_0_0_0_0 = filter.fir_filter_fff(
            1, [1.0 / float(samp_per_sym)] * samp_per_sym)
        self.fir_filter_xxx_0_1_0_0_0_0.declare_sample_delay(
            int((samp_per_sym - 1.0) / 2.0) + 4)
        self.fir_filter_xxx_0_1_0_0_0 = filter.fir_filter_fff(
            1, [1.0 / float(samp_per_sym)] * samp_per_sym)
        self.fir_filter_xxx_0_1_0_0_0.declare_sample_delay(
            int((samp_per_sym - 1.0) / 2.0) + 4)
        self.extract_payload_0_0_0 = extract_payload.extract_payload(
            (1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1), 40 * 8,
            40 * 8)
        self.extract_payload_0_0 = extract_payload.extract_payload(
            (1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1), 40 * 8,
            40 * 8)
        self.extract_payload_0 = extract_payload.extract_payload(
            (1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1), 40 * 8,
            40 * 8)
        self.digital_symbol_sync_xx_0_0_0_0 = digital.symbol_sync_ff(
            digital.TED_GARDNER, samp_per_sym, omega_n_norm, zeta, ted_gain,
            1.5, 1,
            digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, [])
        self.digital_symbol_sync_xx_0_0_0 = digital.symbol_sync_ff(
            digital.TED_GARDNER, samp_per_sym, omega_n_norm, zeta, ted_gain,
            1.5, 1,
            digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, [])
        self.digital_symbol_sync_xx_0_0 = digital.symbol_sync_ff(
            digital.TED_GARDNER, samp_per_sym, omega_n_norm, zeta, ted_gain,
            1.5, 1,
            digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_threshold_ff_0_0_0 = blocks.threshold_ff(-0.2, 0.2, 0)
        self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.2, 0.2, 0)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.2, 0.2, 0)
        self.blocks_streams_to_vector_0_0 = blocks.streams_to_vector(
            gr.sizeof_char * 1, 3)
        self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(
            1, 8, "", False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            1, 8, "", False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            1, 8, "", False, gr.GR_MSB_FIRST)
        self.blocks_float_to_char_0_0_0 = blocks.float_to_char(1, 1)
        self.blocks_float_to_char_0_0 = blocks.float_to_char(1, 1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1, ifile, False, 0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0_0_0_0_1_0 = blocks.file_sink(
            gr.sizeof_char * 1, ofile + "_chn2.bin", False)
        self.blocks_file_sink_0_0_0_0_0_1_0.set_unbuffered(True)
        self.blocks_file_sink_0_0_0_0_0_1 = blocks.file_sink(
            gr.sizeof_char * 1, ofile + "_chn3.bin", False)
        self.blocks_file_sink_0_0_0_0_0_1.set_unbuffered(True)
        self.blocks_file_sink_0_0_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1, ofile + "_chn1.bin", False)
        self.blocks_file_sink_0_0_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(
            gr.sizeof_float * 3,
            '/Users/kesenheimer/Documents/Basteln/SDR/gnuRadio_projects/Somfy/io_homecontrol_96k_sliced.raw',
            False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_char_to_float_0 = blocks.char_to_float(3, 1)
        self.OOK_demodulator_improved_0_1 = OOK_demodulator_improved(
            fbaud=baud_rate,
            freq=dfctr2,
            offset=0.5,
            re_samp_rate=96000,
            samp_rate=samp_rate,
        )
        self.OOK_demodulator_improved_0_0 = OOK_demodulator_improved(
            fbaud=baud_rate,
            freq=dfctr3,
            offset=-0.01,
            re_samp_rate=96000,
            samp_rate=samp_rate,
        )
        self.OOK_demodulator_improved_0 = OOK_demodulator_improved(
            fbaud=baud_rate,
            freq=dfctr1,
            offset=-0.5,
            re_samp_rate=96000,
            samp_rate=samp_rate,
        )

        ##################################################
        # Connections
        ##################################################
        self.connect((self.OOK_demodulator_improved_0, 1),
                     (self.blocks_streams_to_vector_0_0, 0))
        self.connect((self.OOK_demodulator_improved_0, 0),
                     (self.fir_filter_xxx_0_1_0_0_0, 0))
        self.connect((self.OOK_demodulator_improved_0, 2),
                     (self.qtgui_freq_sink_x_1, 0))
        self.connect((self.OOK_demodulator_improved_0_0, 1),
                     (self.blocks_streams_to_vector_0_0, 1))
        self.connect((self.OOK_demodulator_improved_0_0, 0),
                     (self.fir_filter_xxx_0_1_0_0_0_0, 0))
        self.connect((self.OOK_demodulator_improved_0_0, 2),
                     (self.qtgui_freq_sink_x_1, 1))
        self.connect((self.OOK_demodulator_improved_0_1, 1),
                     (self.blocks_streams_to_vector_0_0, 2))
        self.connect((self.OOK_demodulator_improved_0_1, 0),
                     (self.fir_filter_xxx_0_1_0_0_0_0_0, 0))
        self.connect((self.OOK_demodulator_improved_0_1, 2),
                     (self.qtgui_freq_sink_x_1, 2))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.extract_payload_0, 0))
        self.connect((self.blocks_float_to_char_0_0, 0),
                     (self.extract_payload_0_0, 0))
        self.connect((self.blocks_float_to_char_0_0_0, 0),
                     (self.extract_payload_0_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0, 0),
                     (self.blocks_file_sink_0_0_0_0_0_1_0, 0))
        self.connect((self.blocks_streams_to_vector_0_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_threshold_ff_0_0, 0),
                     (self.blocks_float_to_char_0_0, 0))
        self.connect((self.blocks_threshold_ff_0_0_0, 0),
                     (self.blocks_float_to_char_0_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.OOK_demodulator_improved_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.OOK_demodulator_improved_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.OOK_demodulator_improved_0_1, 0))
        self.connect((self.digital_symbol_sync_xx_0_0, 0),
                     (self.blocks_threshold_ff_0, 0))
        self.connect((self.digital_symbol_sync_xx_0_0, 1),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 1))
        self.connect((self.digital_symbol_sync_xx_0_0, 2),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 2))
        self.connect((self.digital_symbol_sync_xx_0_0, 0),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 0))
        self.connect((self.digital_symbol_sync_xx_0_0, 3),
                     (self.qtgui_time_sink_x_0_0_0_0_0, 3))
        self.connect((self.digital_symbol_sync_xx_0_0_0, 0),
                     (self.blocks_threshold_ff_0_0, 0))
        self.connect((self.digital_symbol_sync_xx_0_0_0_0, 0),
                     (self.blocks_threshold_ff_0_0_0, 0))
        self.connect((self.extract_payload_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.extract_payload_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.extract_payload_0_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0_0, 0))
        self.connect((self.fir_filter_xxx_0_1_0_0_0, 0),
                     (self.digital_symbol_sync_xx_0_0, 0))
        self.connect((self.fir_filter_xxx_0_1_0_0_0_0, 0),
                     (self.digital_symbol_sync_xx_0_0_0, 0))
        self.connect((self.fir_filter_xxx_0_1_0_0_0_0_0, 0),
                     (self.digital_symbol_sync_xx_0_0_0_0, 0))