def test_sig_source_square():
    top = gr.top_block()
    src = analog.sig_source_f(1e6, analog.GR_SQR_WAVE, 200e3, 1.0)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, probe)

    return top, probe
def test_sig_source_complex_exponential():
    top = gr.top_block()
    src = analog.sig_source_c(1e6, analog.GR_COS_WAVE, 200e3, 1.0)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, probe)

    return top, probe
Example #3
0
def test_sig_source_complex_exponential():
    top = gr.top_block()
    src = analog.sig_source_c(1e6, analog.GR_COS_WAVE, 200e3, 1.0)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, probe)

    return top, probe
def test_noise_source_real():
    top = gr.top_block()
    src = analog.fastnoise_source_f(analog.GR_UNIFORM, math.sqrt(2))
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, probe)

    return top, probe
def test_null_source_real():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, probe)

    return top, probe
def test_null_source_complex():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, probe)

    return top, probe
Example #7
0
def test_sig_source_square():
    top = gr.top_block()
    src = analog.sig_source_f(1e6, analog.GR_SQR_WAVE, 200e3, 1.0)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, probe)

    return top, probe
Example #8
0
def test_null_source_real():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, probe)

    return top, probe
Example #9
0
def test_null_source_complex():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, probe)

    return top, probe
Example #10
0
def test_noise_source_real():
    top = gr.top_block()
    src = analog.fastnoise_source_f(analog.GR_UNIFORM, math.sqrt(2))
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, probe)

    return top, probe
def test_diff_decoder_bb():
    top = gr.top_block()
    src = digital.glfsr_source_b(7)
    diffdecoder = digital.diff_decoder_bb(2)
    probe = blocks.probe_rate(gr.sizeof_char)
    top.connect(src, diffdecoder, probe)

    return top, probe
def test_binary_slicer_fb():
    top = gr.top_block()
    src = analog.fastnoise_source_f(analog.GR_UNIFORM, math.sqrt(2))
    slicer = digital.binary_slicer_fb()
    probe = blocks.probe_rate(gr.sizeof_char)
    top.connect(src, slicer, probe)

    return top, probe
def test_delay():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    delay = blocks.delay(gr.sizeof_gr_complex, 3000)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, delay, probe)

    return top, probe
def test_five_fir_filter():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    filters = [filter.fir_filter_ccf(1, [random.random() for j in range(256)]) for i in range(5)]
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(*([src] + filters + [probe]))

    return top, probe
def test_conjugate_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    conj = blocks.conjugate_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, conj, probe)

    return top, probe
def test_abs_ff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    abs = blocks.abs_ff()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, abs, probe)

    return top, probe
def test_multiply_const_ff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    mul = blocks.multiply_const_ff(random.random())
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, mul, probe)

    return top, probe
def test_fm_deemph():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    deemph = analog.fm_deemph(30e3, 75e-6)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, deemph, probe)

    return top, probe
def test_complex_to_imag():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    complextoimag = blocks.complex_to_imag()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, complextoimag, probe)

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

    return top, probe
def test_quadrature_demod_cf():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    fdisc = analog.quadrature_demod_cf(5.0)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, fdisc, probe)

    return top, probe
def test_hilbert():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    hilbert = filter.hilbert_fc(257)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, hilbert, probe)

    return top, probe
def test_rotator_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    rotator = blocks.rotator_cc(2*math.pi*(200e3/1e6))
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, rotator, probe)

    return top, probe
def test_multiply_const_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    mul = blocks.multiply_const_cc(complex(random.random(), random.random()))
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, mul, probe)

    return top, probe
def test_iir_filter_ccf():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    iirfilter = filter.iir_filter_ccf([random.random() for _ in range(5)], [random.random() for _ in range(3)])
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, iirfilter, probe)

    return top, probe
Example #26
0
def test_fft_filter_ccf():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    firfilter = filter.fft_filter_ccf(1, [random.random() for _ in range(128)])
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, firfilter, probe)

    return top, probe
Example #27
0
def test_quadrature_demod_cf():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    fdisc = analog.quadrature_demod_cf(5.0)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, fdisc, probe)

    return top, probe
Example #28
0
def test_five_fft_filter():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    filters = [filter.fft_filter_ccf(1, [random.random() for j in range(256)]) for i in range(5)]
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(*([src] + filters + [probe]))

    return top, probe
Example #29
0
def test_binary_slicer_fb():
    top = gr.top_block()
    src = analog.fastnoise_source_f(analog.GR_UNIFORM, math.sqrt(2))
    slicer = digital.binary_slicer_fb()
    probe = blocks.probe_rate(gr.sizeof_char)
    top.connect(src, slicer, probe)

    return top, probe
Example #30
0
def test_rotator_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    rotator = blocks.rotator_cc(2*math.pi*(200e3/1e6))
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, rotator, probe)

    return top, probe
Example #31
0
def test_hilbert():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    hilbert = filter.hilbert_fc(129)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, hilbert, probe)

    return top, probe
Example #32
0
def test_iir_filter_ccf():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    iirfilter = filter.iir_filter_ccf([random.random() for _ in range(5)], [random.random() for _ in range(3)])
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, iirfilter, probe)

    return top, probe
Example #33
0
def test_fm_deemph():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    deemph = analog.fm_deemph(30e3, 75e-6)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, deemph, probe)

    return top, probe
Example #34
0
def test_fft_filter_ccc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    firfilter = filter.fft_filter_ccc(1, [complex(random.random(), random.random()) for _ in range(128)])
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, firfilter, probe)

    return top, probe
Example #35
0
def test_fft_filter_fff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    firfilter = filter.fft_filter_fff(1, [random.random() for _ in range(128)])
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, firfilter, probe)

    return top, probe
def test_fir_filter_fcc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    firfilter = filter.fir_filter_fcc(1, [complex(random.random(), random.random()) for _ in range(256)])
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, firfilter, probe)

    return top, probe
Example #37
0
def test_complex_to_imag():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    complextoimag = blocks.complex_to_imag()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, complextoimag, probe)

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

    return top, probe
def test_fir_filter_fff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    firfilter = filter.fir_filter_fff(1, [random.random() for _ in range(64)])
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, firfilter, probe)

    return top, probe
Example #40
0
def test_conjugate_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    conj = blocks.conjugate_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, conj, probe)

    return top, probe
Example #41
0
def test_delay():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    delay = blocks.delay(gr.sizeof_gr_complex, 3000)
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, delay, probe)

    return top, probe
Example #42
0
def test_multiply_const_ff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    mul = blocks.multiply_const_ff(random.random())
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, mul, probe)

    return top, probe
Example #43
0
def test_abs_ff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    abs = blocks.abs_ff()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, abs, probe)

    return top, probe
Example #44
0
def test_multiply_const_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    mul = blocks.multiply_const_cc(complex(random.random(), random.random()))
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect(src, mul, probe)

    return top, probe
Example #45
0
def test_diff_decoder_bb():
    top = gr.top_block()
    src = digital.glfsr_source_b(7)
    diffdecoder = digital.diff_decoder_bb(2)
    probe = blocks.probe_rate(gr.sizeof_char)
    top.connect(src, diffdecoder, probe)

    return top, probe
def test_multiply_conjugate_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    mul = blocks.multiply_conjugate_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (mul, 0))
    top.connect((src, 0), (mul, 1))
    top.connect(mul, probe)

    return top, probe
Example #47
0
def test_multiply_ff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    mul = blocks.multiply_ff()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect((src, 0), (mul, 0))
    top.connect((src, 0), (mul, 1))
    top.connect(mul, probe)

    return top, probe
Example #48
0
def test_sub_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    sub = blocks.sub_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (sub, 0))
    top.connect((src, 0), (sub, 1))
    top.connect(sub, probe)

    return top, probe
Example #49
0
def test_add_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    add = blocks.add_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (add, 0))
    top.connect((src, 0), (add, 1))
    top.connect(add, probe)

    return top, probe
Example #50
0
def test_multiply_conjugate_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    mul = blocks.multiply_conjugate_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (mul, 0))
    top.connect((src, 0), (mul, 1))
    top.connect(mul, probe)

    return top, probe
def test_float_to_complex():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    floattocomplex = blocks.float_to_complex()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (floattocomplex, 0))
    top.connect((src, 0), (floattocomplex, 1))
    top.connect(floattocomplex, probe)

    return top, probe
def test_sub_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    sub = blocks.sub_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (sub, 0))
    top.connect((src, 0), (sub, 1))
    top.connect(sub, probe)

    return top, probe
def test_add_cc():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_gr_complex)
    add = blocks.add_cc()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (add, 0))
    top.connect((src, 0), (add, 1))
    top.connect(add, probe)

    return top, probe
def test_multiply_ff():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    mul = blocks.multiply_ff()
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect((src, 0), (mul, 0))
    top.connect((src, 0), (mul, 1))
    top.connect(mul, probe)

    return top, probe
Example #55
0
def test_float_to_complex():
    top = gr.top_block()
    src = blocks.null_source(gr.sizeof_float)
    floattocomplex = blocks.float_to_complex()
    probe = blocks.probe_rate(gr.sizeof_gr_complex)
    top.connect((src, 0), (floattocomplex, 0))
    top.connect((src, 0), (floattocomplex, 1))
    top.connect(floattocomplex, probe)

    return top, probe
Example #56
0
def test_file_descriptor_source():
    tmp_f = tempfile.TemporaryFile()
    array.array('f', [random.random() for _ in range(262144)]).tofile(tmp_f)
    tmp_f.seek(0)

    top = gr.top_block()
    src = blocks.file_descriptor_source(gr.sizeof_float, os.dup(tmp_f.fileno()), True)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, probe)

    return top, probe
def test_file_descriptor_source():
    tmp_f = tempfile.TemporaryFile()
    array.array('f', [random.random() for _ in range(262144)]).tofile(tmp_f)
    tmp_f.seek(0)

    top = gr.top_block()
    src = blocks.file_descriptor_source(gr.sizeof_float, os.dup(tmp_f.fileno()), True)
    probe = blocks.probe_rate(gr.sizeof_float)
    top.connect(src, probe)

    return top, probe
Example #58
0
    def test_1(self):
        '''
      Very rough test to ensure that the block can be instantiated and
      data can be run
      '''
        samp_rate = samp_rate = 32000
        freq = freq = samp_rate / 10

        ##################################################
        # Blocks
        ##################################################
        block_buffer = sandia_utils.block_buffer(gr.sizeof_gr_complex, 10000,
                                                 samp_rate, True)
        throttle = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate / 20,
                                   True)
        tag_debug = blocks.tag_debug(gr.sizeof_gr_complex * 1, '', "")
        tag_debug.set_display(True)
        probe_rate = blocks.probe_rate(gr.sizeof_gr_complex * 1, 500.0, 0.15)
        message_debug = blocks.message_debug()
        source = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq, .7,
                                     0, 0)

        ##################################################
        # Connections
        ##################################################
        self.tb.msg_connect((probe_rate, 'rate'), (message_debug, 'store'))
        self.tb.connect((source, 0), (block_buffer, 0))
        self.tb.connect((throttle, 0), (probe_rate, 0))
        self.tb.connect((throttle, 0), (tag_debug, 0))
        self.tb.connect((block_buffer, 0), (throttle, 0))

        # data
        src_data = (1, 1, 2, 2, 3, 3)
        expected_result = (1 + 1j, 2 + 2j, 3 + 3j)

        # execute
        self.tb.start()

        # allow it to run 2 seconds
        time.sleep(3)

        # get number of messages
        nmessages = message_debug.num_messages()

        # should have gotten at least one message
        self.assertTrue(nmessages > 0)

        # clean up
        self.tb.stop()
        self.tb.wait()
Example #59
0
    def __init__(self, config_file='envsim.ini'):
        gr.top_block.__init__(self, "Env Sim Server")

        ##################################################
        # Parameters
        ##################################################
        self.config_file = config_file

        ##################################################
        # Variables
        ##################################################
        self._usrp_ip_prefix_str_config = ConfigParser.ConfigParser()
        self._usrp_ip_prefix_str_config.read(config_file)
        try:
            usrp_ip_prefix_str = self._usrp_ip_prefix_str_config.get(
                'main', 'usrp_ip_prefix')
        except:
            usrp_ip_prefix_str = '192.168.40.'
        self.usrp_ip_prefix_str = usrp_ip_prefix_str
        self._usrp_ip_base_config = ConfigParser.ConfigParser()
        self._usrp_ip_base_config.read(config_file)
        try:
            usrp_ip_base = self._usrp_ip_base_config.getint(
                'main', 'usrp_ip_base')
        except:
            usrp_ip_base = 101
        self.usrp_ip_base = usrp_ip_base
        self.num_nodes = num_nodes = 6
        self.now = now = time.time()
        self._increment_usrp_address_bool_config = ConfigParser.ConfigParser()
        self._increment_usrp_address_bool_config.read(config_file)
        try:
            increment_usrp_address_bool = self._increment_usrp_address_bool_config.getboolean(
                'main', 'increment_usrp_address')
        except:
            increment_usrp_address_bool = True
        self.increment_usrp_address_bool = increment_usrp_address_bool
        self.zmq_base_addr = zmq_base_addr = "tcp://10.169.25.150:"
        self.usrp_ip_list = usrp_ip_list = temp_py_mod.make_usrp_ip_list(
            increment_usrp_address_bool, usrp_ip_prefix_str, usrp_ip_base,
            num_nodes)
        self._samp_rate_config = ConfigParser.ConfigParser()
        self._samp_rate_config.read(config_file)
        try:
            samp_rate = self._samp_rate_config.getfloat('main', 'samp_rate')
        except:
            samp_rate = 2e6
        self.samp_rate = samp_rate
        self._port_num_base_config = ConfigParser.ConfigParser()
        self._port_num_base_config.read(config_file)
        try:
            port_num_base = self._port_num_base_config.getint(
                'main', 'port_num_base')
        except:
            port_num_base = 52001
        self.port_num_base = port_num_base
        self._noise_amp_config = ConfigParser.ConfigParser()
        self._noise_amp_config.read(config_file)
        try:
            noise_amp = self._noise_amp_config.getfloat('main', 'noise_amp')
        except:
            noise_amp = .001
        self.noise_amp = noise_amp
        self._host_config = ConfigParser.ConfigParser()
        self._host_config.read(config_file)
        try:
            host = self._host_config.get('main', 'host_ip')
        except:
            host = '192.168.40.2'
        self.host = host
        self.env_time_int_s = env_time_int_s = int(now)
        self.env_time_frac_s = env_time_frac_s = now - int(now)
        self._channel_gain_linear_config = ConfigParser.ConfigParser()
        self._channel_gain_linear_config.read(config_file)
        try:
            channel_gain_linear = self._channel_gain_linear_config.getfloat(
                'main', 'channel_gain_linear')
        except:
            channel_gain_linear = .01
        self.channel_gain_linear = channel_gain_linear

        ##################################################
        # Blocks
        ##################################################
        self.envsim_zmq_envsim_source_0_2_0_0 = envsim.zmq_envsim_source(
            "tcp://" + usrp_ip_list[2] + ":" + str(port_num_base + 2), 10, 100,
            samp_rate, env_time_int_s, env_time_frac_s)

        self.envsim_zmq_envsim_source_0_2_0 = envsim.zmq_envsim_source(
            "tcp://" + usrp_ip_list[1] + ":" + str(port_num_base + 1), 10, 100,
            samp_rate, env_time_int_s, env_time_frac_s)

        self.envsim_zmq_envsim_source_0_2 = envsim.zmq_envsim_source(
            "tcp://" + usrp_ip_list[0] + ":" + str(port_num_base + 0), 10, 100,
            samp_rate, env_time_int_s, env_time_frac_s)

        self.envsim_zmq_envsim_source_0_1 = envsim.zmq_envsim_source(
            "tcp://" + usrp_ip_list[3] + ":" + str(port_num_base + 3), 10, 100,
            samp_rate, env_time_int_s, env_time_frac_s)

        self.envsim_zmq_envsim_source_0_0 = envsim.zmq_envsim_source(
            "tcp://" + usrp_ip_list[4] + ":" + str(port_num_base + 4), 10, 100,
            samp_rate, env_time_int_s, env_time_frac_s)

        self.envsim_zmq_envsim_source_0 = envsim.zmq_envsim_source(
            "tcp://" + usrp_ip_list[5] + ":" + str(port_num_base + 5), 10, 100,
            samp_rate, env_time_int_s, env_time_frac_s)

        self.envsim_socket_meta_pdu_0_2 = envsim.socket_meta_pdu(
            "UDP_CLIENT", usrp_ip_list[0], str(port_num_base + 0), 40000,
            False)
        self.envsim_socket_meta_pdu_0_1_3 = envsim.socket_meta_pdu(
            "UDP_CLIENT", usrp_ip_list[2], str(port_num_base + 2), 40000,
            False)
        self.envsim_socket_meta_pdu_0_1_2_0 = envsim.socket_meta_pdu(
            "UDP_CLIENT", usrp_ip_list[5], str(port_num_base + 5), 40000,
            False)
        self.envsim_socket_meta_pdu_0_1_1_0 = envsim.socket_meta_pdu(
            "UDP_CLIENT", usrp_ip_list[4], str(port_num_base + 4), 40000,
            False)
        self.envsim_socket_meta_pdu_0_1_0_0 = envsim.socket_meta_pdu(
            "UDP_CLIENT", usrp_ip_list[3], str(port_num_base + 3), 40000,
            False)
        self.envsim_socket_meta_pdu_0_0_0 = envsim.socket_meta_pdu(
            "UDP_CLIENT", usrp_ip_list[1], str(port_num_base + 1), 40000,
            False)
        self.channels_sro_model_0_1 = channels.sro_model(
            samp_rate, 0.01, 1e3, 2)
        self.channels_sro_model_0_0 = channels.sro_model(
            samp_rate, 0.01, 1e3, 1)
        self.channels_sro_model_0 = channels.sro_model(samp_rate, 0.01, 1e3, 0)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, 'packet_len')
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, 'packet_len')
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_gr_complex, 1, 2048, "packet_len")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_gr_complex, 1, 2048, "packet_len")
        self.blocks_probe_rate_0 = blocks.probe_rate(gr.sizeof_gr_complex * 1,
                                                     5000.0, 0.15)
        self.blocks_multiply_const_xx_0_0 = blocks.multiply_const_cc(
            channel_gain_linear)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc(
            channel_gain_linear)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_float_to_complex_0_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_complex_to_float_0_1 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(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.analog_rail_ff_0_2 = analog.rail_ff(-1.0, 1.0)
        self.analog_rail_ff_0_1 = analog.rail_ff(-1.0, 1.0)
        self.analog_rail_ff_0_0_1 = analog.rail_ff(-1.0, 1.0)
        self.analog_rail_ff_0_0_0 = analog.rail_ff(-1.0, 1.0)
        self.analog_rail_ff_0_0 = analog.rail_ff(-1.0, 1.0)
        self.analog_rail_ff_0 = analog.rail_ff(-1.0, 1.0)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, noise_amp, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_probe_rate_0, 'rate'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.envsim_socket_meta_pdu_0_1_0_0, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.envsim_socket_meta_pdu_0_1_1_0, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.envsim_socket_meta_pdu_0_1_2_0, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'),
                         (self.envsim_socket_meta_pdu_0_0_0, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'),
                         (self.envsim_socket_meta_pdu_0_1_3, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'),
                         (self.envsim_socket_meta_pdu_0_2, 'pdus'))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0_0, 0))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0_0_0, 1))
        self.connect((self.analog_rail_ff_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.analog_rail_ff_0_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_rail_ff_0_0_0, 0),
                     (self.blocks_float_to_complex_0_0, 0))
        self.connect((self.analog_rail_ff_0_0_1, 0),
                     (self.blocks_float_to_complex_0_1, 0))
        self.connect((self.analog_rail_ff_0_1, 0),
                     (self.blocks_float_to_complex_0_0, 1))
        self.connect((self.analog_rail_ff_0_2, 0),
                     (self.blocks_float_to_complex_0_1, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_const_xx_0, 0))
        self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_add_xx_0_0_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.blocks_add_xx_0_1, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0_1, 0),
                     (self.blocks_multiply_const_xx_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.analog_rail_ff_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.analog_rail_ff_0_0, 0))
        self.connect((self.blocks_complex_to_float_0_0, 0),
                     (self.analog_rail_ff_0_0_0, 0))
        self.connect((self.blocks_complex_to_float_0_0, 1),
                     (self.analog_rail_ff_0_1, 0))
        self.connect((self.blocks_complex_to_float_0_1, 0),
                     (self.analog_rail_ff_0_0_1, 0))
        self.connect((self.blocks_complex_to_float_0_1, 1),
                     (self.analog_rail_ff_0_2, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.channels_sro_model_0_1, 0))
        self.connect((self.blocks_float_to_complex_0_0, 0),
                     (self.channels_sro_model_0_0, 0))
        self.connect((self.blocks_float_to_complex_0_1, 0),
                     (self.channels_sro_model_0, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0),
                     (self.blocks_add_xx_0_0, 1))
        self.connect((self.blocks_multiply_const_xx_0_0, 0),
                     (self.blocks_add_xx_0_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_probe_rate_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.channels_sro_model_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.channels_sro_model_0_0, 0),
                     (self.blocks_add_xx_0, 2))
        self.connect((self.channels_sro_model_0_1, 0),
                     (self.blocks_add_xx_0, 3))
        self.connect((self.envsim_zmq_envsim_source_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.envsim_zmq_envsim_source_0_0, 0),
                     (self.blocks_complex_to_float_0_0, 0))
        self.connect((self.envsim_zmq_envsim_source_0_1, 0),
                     (self.blocks_complex_to_float_0_1, 0))
        self.connect((self.envsim_zmq_envsim_source_0_2, 0),
                     (self.blocks_add_xx_0_1, 0))
        self.connect((self.envsim_zmq_envsim_source_0_2_0, 0),
                     (self.blocks_add_xx_0_1, 1))
        self.connect((self.envsim_zmq_envsim_source_0_2_0_0, 0),
                     (self.blocks_add_xx_0_1, 2))
Example #60
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.variable_function_probe_0 = variable_function_probe_0 = 0
        self.sample_rate = sample_rate = 1e6
        self.vector_length = vector_length = 1
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = variable_function_probe_0
        self.suppress_tune_transients_chooser = suppress_tune_transients_chooser = 0
        self.source_min_output_buffer = source_min_output_buffer = 2**14*4
        self.max_sample_rate = max_sample_rate = 122.88e6
        self.max_attenuation = max_attenuation = 5000
        self.center_freq = center_freq = 915e6
        self.bandwidth = bandwidth = sample_rate
        self.atten_quart_db = atten_quart_db = 55

        ##################################################
        # Blocks
        ##################################################
        self._sample_rate_range = Range(0.1e6, max_sample_rate, 0.1e6, 1e6, 200)
        self._sample_rate_win = RangeWidget(self._sample_rate_range, self.set_sample_rate, 'Sample Rate', "counter_slider", float)
        self.top_grid_layout.addWidget(self._sample_rate_win, 1, 0, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)]
        self._suppress_tune_transients_chooser_options = (0, 1, )
        self._suppress_tune_transients_chooser_labels = ('False', 'True', )
        self._suppress_tune_transients_chooser_tool_bar = Qt.QToolBar(self)
        self._suppress_tune_transients_chooser_tool_bar.addWidget(Qt.QLabel('Suppress Tune Transients'+": "))
        self._suppress_tune_transients_chooser_combo_box = Qt.QComboBox()
        self._suppress_tune_transients_chooser_tool_bar.addWidget(self._suppress_tune_transients_chooser_combo_box)
        for label in self._suppress_tune_transients_chooser_labels: self._suppress_tune_transients_chooser_combo_box.addItem(label)
        self._suppress_tune_transients_chooser_callback = lambda i: Qt.QMetaObject.invokeMethod(self._suppress_tune_transients_chooser_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._suppress_tune_transients_chooser_options.index(i)))
        self._suppress_tune_transients_chooser_callback(self.suppress_tune_transients_chooser)
        self._suppress_tune_transients_chooser_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_suppress_tune_transients_chooser(self._suppress_tune_transients_chooser_options[i]))
        self.top_layout.addWidget(self._suppress_tune_transients_chooser_tool_bar)
        self._center_freq_range = Range(100e6, 6000e6, 1e6, 915e6, 200)
        self._center_freq_win = RangeWidget(self._center_freq_range, self.set_center_freq, 'Frequency', "counter_slider", float)
        self.top_grid_layout.addWidget(self._center_freq_win, 0, 0, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)]
        self.blocks_probe_rate_0 = blocks.probe_rate(gr.sizeof_gr_complex*1, 500.0, 0.15)
        self._bandwidth_range = Range(0.1e6, max_sample_rate, 0.1e6, sample_rate, 200)
        self._bandwidth_win = RangeWidget(self._bandwidth_range, self.set_bandwidth, 'Bandwidth', "counter_slider", float)
        self.top_grid_layout.addWidget(self._bandwidth_win, 1, 1, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(1,2)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(1,2)]
        self._atten_quart_db_range = Range(1, max_attenuation, 1, 55, 200)
        self._atten_quart_db_win = RangeWidget(self._atten_quart_db_range, self.set_atten_quart_db, 'Attenuation ', "counter_slider", float)
        self.top_grid_layout.addWidget(self._atten_quart_db_win, 0, 1, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(0,1)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(1,2)]
        self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self)

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

        self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel('Rx Rate'+": "))
        self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0)))
        self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label)
        self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 5, 0, 1, 1)
        [self.top_grid_layout.setRowStretch(r,1) for r in range(5,6)]
        [self.top_grid_layout.setColumnStretch(c,1) for c in range(0,1)]

        def _variable_function_probe_0_probe():
            while True:
                val = self.blocks_probe_rate_0.rate()
                try:
                    self.set_variable_function_probe_0(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (10))
        _variable_function_probe_0_thread = threading.Thread(target=_variable_function_probe_0_probe)
        _variable_function_probe_0_thread.daemon = True
        _variable_function_probe_0_thread.start()

        self.sidekiq_sidekiq_tx_0 = sidekiq.sidekiq_tx(sample_rate, atten_quart_db, center_freq, bandwidth, 1, bool(suppress_tune_transients_chooser),
                0, 32764, ())

        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex*1, '', ""); self.blocks_tag_debug_0.set_display(True)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.analog_sig_source_x_0 = analog.sig_source_c(sample_rate, analog.GR_COS_WAVE, 1000, 0, 0)
        (self.analog_sig_source_x_0).set_min_output_buffer(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.sidekiq_sidekiq_tx_0, 'telemetry'), (self.blocks_message_debug_0, 'print'))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_probe_rate_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_tag_debug_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0), (self.sidekiq_sidekiq_tx_0, 0))