def __init__(self, options, options_vr1, options_vr2): gr.top_block.__init__(self) if (options.file_sink is False): print("Using USRP") self.sink = uhd_transmitter(options.args, options.bandwidth, options.tx_freq, options.lo_offset, options.tx_gain, options.spec, options.antenna, options.clock_source, options.verbose) else: self.sink = blocks.null_sink(gr.sizeof_gr_complex) vr_configs = [] vr_configs.append([options_vr1.freq, options_vr1.bandwidth]) vr_configs.append([options_vr2.freq, options_vr2.bandwidth]) hydra_sink = hydra.hydra_sink(2, options.fft_length, int(options.tx_freq), int(options.bandwidth), vr_configs) self.vr1_source = zeromq.pull_source(gr.sizeof_gr_complex, 1, 'tcp://192.168.122.56:4000', 100, False, -1) self.vr2_source = zeromq.pull_source(gr.sizeof_gr_complex, 1, 'tcp://192.168.122.208:4001', 100, False, -1) self.connect(self.vr1_source, (hydra_sink, 0), self.sink) self.connect(self.vr2_source, (hydra_sink, 1)) self.hydra = hydra_sink self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", 12345), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start()
def __init__(self, ipp1="127.0.0.1", ipp2="127.0.0.1", ipp3="127.0.0.1", ipp4="127.0.0.1", iptx="127.0.0.1", samp_rate=10000): gr.top_block.__init__(self, "OFDM Rx") ################################################## # Parameters ################################################## self.ipp1 = ipp1 self.ipp2 = ipp2 self.ipp3 = ipp3 self.ipp4 = ipp4 self.iptx = iptx self.samp_rate = samp_rate ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [0j, 0j, 0j, 0j, 0j, 0j, (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1 +0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), 0j, (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), 0j, 0j, 0j, 0j, 0j] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len = packet_len = 96 self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) ################################################## # Blocks ################################################## self.zeromq_push_sink_0_0_1_0 = zeromq.push_sink(gr.sizeof_gr_complex, 64, "tcp://"+ ipp2 + ":55521", 100, True) self.zeromq_push_sink_0_0_1 = zeromq.push_sink(gr.sizeof_gr_complex, 64, "tcp://"+ ipp2 + ":55520", 100, True) self.zeromq_pull_source_0_0_0 = zeromq.pull_source(gr.sizeof_char, 1, "tcp://"+ ipp1 + ":55511", 100, True) self.zeromq_pull_source_0_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, "tcp://"+ ipp1 + ":55510", 100, True) self.zeromq_pull_msg_source_0 = zeromq.pull_msg_source("tcp://"+ ipp3 + ":55530", 100) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len/4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), ) ################################################## # Connections ################################################## self.msg_connect((self.zeromq_pull_msg_source_0, 'out'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.digital_header_payload_demux_0, 0), (self.zeromq_push_sink_0_0_1, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.zeromq_push_sink_0_0_1_0, 0)) self.connect((self.zeromq_pull_source_0_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.zeromq_pull_source_0_0_0, 0), (self.digital_header_payload_demux_0, 1))
def __init__(self, samp_rate, freq, gain, bw, port): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.gain = gain self.freq = freq self.bw = bw ################################################## # Blocks ################################################## #self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, "/tmp/send_test.complex", False) #self.blocks_file_sink_0.set_unbuffered(True) # self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate, True) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "bladerf") self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(gain, 0) # self.osmosdr_sink_0.set_if_gain(gain, 0) # self.osmosdr_sink_0.set_bb_gain(gain, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(bw, 0) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:' + str(port)) ################################################## # Connections ################################################## #self.connect((self.blks2_tcp_source_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self, samp_rate, freq, gain, bw, device_args, port): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.gain = gain self.freq = freq self.bw = bw ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink(device_args, uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_bandwidth(bw, 0) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:'+str(port)) ################################################## # Connections ################################################## self.connect((self.zeromq_pull_source_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self, samp_rate, freq, gain, if_gain, baseband_gain, bw, port): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.gain = gain self.freq = freq self.bw = bw ################################################## # Blocks ################################################## #self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, "/tmp/send_test.complex", False) #self.blocks_file_sink_0.set_unbuffered(True) # self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate, True) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "hackrf") self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(gain, 0) self.osmosdr_sink_0.set_if_gain(if_gain, 0) self.osmosdr_sink_0.set_bb_gain(baseband_gain, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(bw, 0) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:' + str(port)) ################################################## # Connections ################################################## #self.connect((self.blks2_tcp_source_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self, samp_rate, freq, gain, bw, device_args, port): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.gain = gain self.freq = freq self.bw = bw ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( device_args, uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_bandwidth(bw, 0) self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:' + str(port)) ################################################## # Connections ################################################## self.connect((self.zeromq_pull_source_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self, ipp1="127.0.0.1", ipp2="127.0.0.1", ipp3="127.0.0.1", ipp4="127.0.0.1", iptx="127.0.0.1", samp_rate=100): gr.top_block.__init__(self, "OFDM Rx") ################################################## # Parameters ################################################## self.ipp1 = ipp1 self.ipp2 = ipp2 self.ipp3 = ipp3 self.ipp4 = ipp4 self.iptx = iptx self.samp_rate = samp_rate ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [0j, 0j, 0j, 0j, 0j, 0j, (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1 +0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), 0j, (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), 0j, 0j, 0j, 0j, 0j] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len = packet_len = 96 self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) ################################################## # Blocks ################################################## self.zeromq_pull_source_0_0_0_0_0_0 = zeromq.pull_source(gr.sizeof_gr_complex, 64, "tcp://" + ipp2 + ":55521", 100, True) self.my_number_sync_timestamp_0 = my.number_sync_timestamp() self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, "", True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc(payload_equalizer.base(), fft_len/4, length_tag_key, True, 0) self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key, True) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb(payload_mod.base()) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) ################################################## # Connections ################################################## self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_1, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.my_number_sync_timestamp_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.digital_constellation_decoder_cb_1, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0)) self.connect((self.zeromq_pull_source_0_0_0_0_0_0, 0), (self.fft_vxx_1, 0))
def __init__(self, ipp1="127.0.0.1", ipp2="127.0.0.1", ipp3="127.0.0.1", ipp4="127.0.0.1", iptx="127.0.0.1", samp_rate=10000): gr.top_block.__init__(self, "OFDM Rx") ################################################## # Parameters ################################################## self.ipp1 = ipp1 self.ipp2 = ipp2 self.ipp3 = ipp3 self.ipp4 = ipp4 self.iptx = iptx self.samp_rate = samp_rate ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [0j, 0j, 0j, 0j, 0j, 0j, (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1 +0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), 0j, (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), 0j, 0j, 0j, 0j, 0j] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.packet_len = packet_len = 96 self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) ################################################## # Blocks ################################################## self.zeromq_push_sink_0_0_0 = zeromq.push_sink(gr.sizeof_char, 1, "tcp://"+ ipp1 + ":55511", 100, True) self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://"+ ipp1 + ":55510", 100, True) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, "tcp://"+ iptx + ":55500", 100, True) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(fft_len, fft_len/4, False) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, fft_len+fft_len/4) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(-2.0/fft_len) ################################################## # Connections ################################################## self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_multiply_xx_1, 0), (self.zeromq_push_sink_0_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.zeromq_push_sink_0_0_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0))
def test_001 (self): vlen = 10 src_data = range(vlen)*100 src = blocks.vector_source_f(src_data, False, vlen) zeromq_push_sink = zeromq.push_sink(gr.sizeof_float, vlen, "tcp://127.0.0.1:5555") zeromq_pull_source = zeromq.pull_source(gr.sizeof_float, vlen, "tcp://127.0.0.1:5555", 0) sink = blocks.vector_sink_f(vlen) self.tb.connect(src, zeromq_push_sink) self.tb.connect(zeromq_pull_source, sink) self.tb.start() time.sleep(0.25) self.tb.stop() self.tb.wait() self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
def test_001(self): vlen = 10 src_data = range(vlen) * 100 src = blocks.vector_source_f(src_data, False, vlen) zeromq_push_sink = zeromq.push_sink(gr.sizeof_float, vlen, "tcp://127.0.0.1:5557") zeromq_pull_source = zeromq.pull_source(gr.sizeof_float, vlen, "tcp://127.0.0.1:5557", 0) sink = blocks.vector_sink_f(vlen) self.tb.connect(src, zeromq_push_sink) self.tb.connect(zeromq_pull_source, sink) self.tb.start() time.sleep(0.25) self.tb.stop() self.tb.wait() self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
def test_001(self): vlen = 10 src_data = list(range(vlen)) * 100 src = blocks.vector_source_f(src_data, False, vlen) zeromq_push_sink = zeromq.push_sink("tcp://127.0.0.1:0") address = zeromq_push_sink.last_endpoint() zeromq_pull_source = zeromq.pull_source(address, 0) sink = blocks.vector_sink_f(vlen) self.send_tb.connect(src, zeromq_push_sink) self.recv_tb.connect(zeromq_pull_source, sink) self.recv_tb.start() # time.sleep(0.5) self.send_tb.start() time.sleep(0.5) self.recv_tb.stop() self.send_tb.stop() self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
def test_001 (self): vlen = 10 src_data = list(range(vlen))*100 src = blocks.vector_source_f(src_data, False, vlen) zeromq_push_sink = zeromq.push_sink(gr.sizeof_float, vlen, "tcp://127.0.0.1:0") address = zeromq_push_sink.last_endpoint() zeromq_pull_source = zeromq.pull_source(gr.sizeof_float, vlen, address, 0) sink = blocks.vector_sink_f(vlen) self.send_tb.connect(src, zeromq_push_sink) self.recv_tb.connect(zeromq_pull_source, sink) self.recv_tb.start() time.sleep(0.5) self.send_tb.start() time.sleep(0.5) self.recv_tb.stop() self.send_tb.stop() self.recv_tb.wait() self.send_tb.wait() self.assertFloatTuplesAlmostEqual(sink.data(), src_data)
def __init__(self): gr.top_block.__init__(self, "SDR RX Test") Qt.QWidget.__init__(self) self.setWindowTitle("SDR RX Test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "demo_record_host") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.velocity_factor = velocity_factor = 0.69 self.vec_length = vec_length = 1 self.speed_of_light = speed_of_light = 299792458 self.samp_rate = samp_rate = 1e6 self.rx_gain_A2 = rx_gain_A2 = 60 self.rf_freq = rf_freq = 432e6 self.fft_size = fft_size = 1024 self.client_address = client_address = "192.168.10.184" ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'Real-Time Display') self.top_grid_layout.addWidget(self.tabs, 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._rf_freq_range = Range(100e6, 6000e6, 1e6, 432e6, 100) self._rf_freq_win = RangeWidget(self._rf_freq_range, self.set_rf_freq, 'RF Freq', "counter_slider", float) self.tabs_grid_layout_0.addWidget(self._rf_freq_win, 0, 0, 1, 1) for r in range(0, 1): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.zeromq_pull_source_1_0_0 = zeromq.pull_source( gr.sizeof_char, 1024, 'tcp://192.168.10.184:4001', 100, True, -1) self.zeromq_pull_source_1_0 = zeromq.pull_source( gr.sizeof_char, 1024, 'tcp://192.168.10.184:4000', 100, True, -1) self.zeromq_pull_source_1 = zeromq.pull_source( gr.sizeof_gr_complex, vec_length, 'tcp://192.168.10.184:9998', 100, False, -1) self.xmlrpc_client0_0 = xmlrpclib.Server('http://192.168.10.184:30000') self.xmlrpc_client0 = xmlrpclib.Server('http://192.168.10.184:30000') self._rx_gain_A2_range = Range(0, 80, 1, 60, 100) self._rx_gain_A2_win = RangeWidget(self._rx_gain_A2_range, self.set_rx_gain_A2, 'RX Gain', "counter_slider", float) self.tabs_grid_layout_0.addWidget(self._rx_gain_A2_win, 0, 1, 1, 1) for r in range(0, 1): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( fft_size, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rf_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [3, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 2, 1, 1, 1) for r in range(2, 3): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( fft_size, #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(-0.05, 0.05) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: 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.tabs_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 2, 0, 1, 1) for r in range(2, 3): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_size, #size firdes.WIN_HANN, #wintype rf_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.1) self.qtgui_freq_sink_x_0.set_y_axis(-100, -20) self.qtgui_freq_sink_x_0.set_y_label('Amplitude', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', 'RXA', 'RXB', '', '', '', '', '', '', ''] widths = [1, 2, 2, 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.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 1, 1, 1, 1) for r in range(1, 2): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( fft_size, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-0.05, 0.05) self.qtgui_const_sink_x_0.set_x_axis(-0.05, 0.05) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1, 1) for r in range(1, 2): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.blocks_throttle_0 = blocks.throttle( gr.sizeof_gr_complex * vec_length, samp_rate, True) self.blocks_null_sink_1_0 = blocks.null_sink(gr.sizeof_char * 1024) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1024) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * vec_length) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.zeromq_pull_source_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.zeromq_pull_source_1, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.zeromq_pull_source_1, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.zeromq_pull_source_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.zeromq_pull_source_1, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.zeromq_pull_source_1_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.zeromq_pull_source_1_0_0, 0), (self.blocks_null_sink_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "Run Music Lin Array X310 Twinrx") ################################################## # Variables ################################################## self.input_variables = input_variables = struct({ "NumArrayElements": 2, "NormSpacing": 0.33, "SnapshotSize": 2**11, "OverlapSize": 2**9, "NumTargets": 1, "PSpectrumLength": 2**10, "DirectoryConfigFiles": "/home/donnie", "RelativePhaseOffsets": "measure_X310_TwinRX_relative_phase_offsets_245.cfg", }) self.rel_phase_offsets_file_name = rel_phase_offsets_file_name = os.path.join( input_variables.DirectoryConfigFiles, input_variables.RelativePhaseOffsets) ################################################## # Blocks ################################################## self.zeromq_pull_source_0_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, "tcp://192.168.1.20:9998", 100, False, -1) self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, "tcp://192.168.1.20:9999", 100, False, -1) self.phase_correct_hier_1 = doa.phase_correct_hier( num_ports=input_variables.NumArrayElements, config_filename=rel_phase_offsets_file_name, ) self.doa_find_local_max_0 = doa.find_local_max( input_variables.NumTargets, input_variables.PSpectrumLength, 0.0, 180.0) self.doa_average_and_save_0 = doa.average_and_save( 5000, input_variables.NumTargets, "/home/donnie/daniel/PyProj/data.cfg") self.doa_autocorrelate_0 = doa.autocorrelate( input_variables.NumArrayElements, input_variables.SnapshotSize, input_variables.OverlapSize, 1) self.doa_MUSIC_lin_array_0 = doa.MUSIC_lin_array( input_variables.NormSpacing, input_variables.NumTargets, input_variables.NumArrayElements, input_variables.PSpectrumLength) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * input_variables.NumTargets) ################################################## # Connections ################################################## self.connect((self.doa_MUSIC_lin_array_0, 0), (self.doa_find_local_max_0, 0)) self.connect((self.doa_autocorrelate_0, 0), (self.doa_MUSIC_lin_array_0, 0)) self.connect((self.doa_find_local_max_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.doa_find_local_max_0, 1), (self.doa_average_and_save_0, 0)) self.connect((self.phase_correct_hier_1, 0), (self.doa_autocorrelate_0, 0)) self.connect((self.phase_correct_hier_1, 1), (self.doa_autocorrelate_0, 1)) self.connect((self.zeromq_pull_source_0, 0), (self.phase_correct_hier_1, 0)) self.connect((self.zeromq_pull_source_0_0, 0), (self.phase_correct_hier_1, 1))
def __init__(self): gr.top_block.__init__(self, "Obcemulatorexample") Qt.QWidget.__init__(self) self.setWindowTitle("Obcemulatorexample") 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", "OBCEmulatorExample") 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 = 16000 self.frequency = frequency = 1000 self.amplitude = amplitude = 1.0 ################################################## # Blocks ################################################## self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:5557', 1000, False, -1) self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:5556', 1000, False, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer(('localhost', 8080), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread( target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 3000, #size samp_rate, #samp_rate 'Input From OBC', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-2.5, 2.5) self.qtgui_time_sink_x_0_0.set_y_label("", "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 3000, #size samp_rate, #samp_rate 'Output to OBC', #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(-2.5, 2.5) self.qtgui_time_sink_x_0.set_y_label("", "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, frequency, amplitude, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.blocks_throttle_0_0, 0))
def __init__( self, ipp1="127.0.0.1", ipp2="127.0.0.1", ipp3="127.0.0.1", ipp4="127.0.0.1", iptx="127.0.0.1", samp_rate=1000 ): gr.top_block.__init__(self, "OFDM Rx") ################################################## # Parameters ################################################## self.ipp1 = ipp1 self.ipp2 = ipp2 self.ipp3 = ipp3 self.ipp4 = ipp4 self.iptx = iptx self.samp_rate = samp_rate ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [ 0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), 0j, 0j, 0j, 0j, 0j, ] self.sync_word1 = sync_word1 = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ] self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1 ) self.packet_len = packet_len = 96 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False, ) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols ) ################################################## # Blocks ################################################## self.zeromq_push_sink_0_0_1_0_0 = zeromq.push_sink(gr.sizeof_char, 1, "tcp://" + ipp3 + ":55530", 100, True) self.zeromq_push_sink_0_0_1_0 = zeromq.push_sink( gr.sizeof_gr_complex, 64, "tcp://" + ipp2 + ":55521", 100, True ) self.zeromq_push_sink_0_0_1 = zeromq.push_sink(gr.sizeof_gr_complex, 64, "tcp://" + ipp2 + ":55520", 100, True) self.zeromq_push_sink_0_0_0 = zeromq.push_sink(gr.sizeof_char, 1, "tcp://" + ipp1 + ":55511", 100, True) self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://" + ipp1 + ":55510", 100, True) self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://" + iptx + ":55500", 100, True) self.zeromq_pull_source_0_0_0_0_0_0 = zeromq.pull_source( gr.sizeof_gr_complex, 64, "tcp://" + ipp2 + ":55521", 100, True ) self.zeromq_pull_source_0_0_0_0_0 = zeromq.pull_source( gr.sizeof_gr_complex, 64, "tcp://" + ipp2 + ":55520", 100, True ) self.zeromq_pull_source_0_0_0_0 = zeromq.pull_source(gr.sizeof_char, 1, "tcp://" + ipp3 + ":55530", 100, True) self.zeromq_pull_source_0_0_0 = zeromq.pull_source(gr.sizeof_char, 1, "tcp://" + ipp1 + ":55511", 100, True) self.zeromq_pull_source_0_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, "tcp://" + ipp1 + ":55510", 100, True) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, "tcp://" + iptx + ":55500", 100, True) self.my_random_source_limit_rate_0 = my.random_source_limit_rate(1000) self.my_number_sync_timestamp_0 = my.number_sync_timestamp() self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(header_formatter.base()) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=packet_length_tag_key, occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, rolloff=0, debug_log=True, scramble_bits=False, ) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(fft_len, fft_len / 4, False) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, "", True ) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, "", 0, "", True ) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), fft_len / 4, length_tag_key, True, 0 ) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len / 4, length_tag_key, True, 1 ) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len / 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, () ) self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key, True) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb(payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.1, frequency_offset=0 * 1.0 / fft_len, epsilon=1.0, taps=(1.0,), noise_seed=0, block_tags=True, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tag_debug_1 = blocks.tag_debug(gr.sizeof_char * 1, "Rx Bytes", "") self.blocks_tag_debug_1.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, packet_length_tag_key ) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST ) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len / 4) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(-2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect( (self.digital_packet_headerparser_b_0, "header_data"), (self.digital_header_payload_demux_0, "header_data") ) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.zeromq_push_sink_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.zeromq_push_sink_0_0_1_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_1, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_tag_debug_1, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.my_number_sync_timestamp_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.zeromq_push_sink_0_0_1, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.zeromq_push_sink_0_0_1_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.digital_constellation_decoder_cb_1, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.zeromq_push_sink_0_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0)) self.connect((self.my_random_source_limit_rate_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.zeromq_pull_source_0_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.zeromq_pull_source_0_0_0, 0), (self.digital_header_payload_demux_0, 1)) self.connect((self.zeromq_pull_source_0_0_0_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.zeromq_pull_source_0_0_0_0_0, 0), (self.fft_vxx_0, 0)) self.connect((self.zeromq_pull_source_0_0_0_0_0_0, 0), (self.fft_vxx_1, 0))
def __init__(self): gr.top_block.__init__(self, "Envsim Viewer") Qt.QWidget.__init__(self) self.setWindowTitle("Envsim Viewer") 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", "envsim_viewer") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.zmq_base_addr = zmq_base_addr = "tcp://10.169.25.92:" self.samp_rate = samp_rate = 1e6 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 ################################################## # Blocks ################################################## self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, zmq_base_addr + str(port_num_base + 3), 100, False, -1) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 25) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) ################################################## # Connections ################################################## self.connect((self.zeromq_pull_source_0, 0), (self.qtgui_sink_x_0, 0))
def __init__(self, rf_params, tcp_test, sdr_sel): gr.hier_block2.__init__( self, "RX Source Block", gr.io_signature(0, 0, 0), # no inputs gr.io_signature(1, 1, gr.sizeof_gr_complex * 1) # single out ) # parameters self.rf_params = rf_params self.tcp_test = tcp_test self.sdr_sel = sdr_sel # instantiate the IQ source ## use the ZeroMQ Pull Source for loopback connection to TX if self.sdr_sel == rfm.HW_TEST: self.src = zeromq.pull_source(gr.sizeof_gr_complex, 1, self.tcp_test, 100, False, -1) elif self.sdr_sel == rfm.HW_UHD: self.src = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.src.set_antenna('TX/RX', 0) self.src.set_center_freq(rf_params.center_freq, 0) self.src.set_gain(rf_params.rx_gain, 0) self.src.set_samp_rate(rf_params.samp_rate) elif self.sdr_sel == rfm.HW_HACKRF: self.src = osmosdr.source(args="numchan=" + str(1) + " " + 'hackrf=0') self.src.set_sample_rate(self.rf_params.samp_rate) self.src.set_center_freq(self.rf_params.center_freq, 0) self.src.set_freq_corr(0, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) self.src.set_gain_mode(False, 0) # mapping single value gain to hackrf's 3 stages as follows: # Gain -> RF IF BB # 0 0 0 0 # 20 0 8 8 # 30 0 16 16 # 40 14 16 16 # 60 14 24 24 # 80 14 32 32 if rf_params.rx_gain == 0: rfg, ifg, bbg = 0, 0, 0 elif rf_params.rx_gain == 20: rfg, ifg, bbg = 0, 0, 0 elif rf_params.rx_gain == 30: rfg, ifg, bbg = 0, 16, 16 elif rf_params.rx_gain == 40: rfg, ifg, bbg = 0, 24, 24 elif rf_params.rx_gain == 60: rfg, ifg, bbg = 14, 24, 24 elif rf_params.rx_gain == 80: rfg, ifg, bbg = 14, 32, 32 else: rfg, ifg, bbg = 0, 16, 16 self.src.set_gain(rfg, 0) self.src.set_if_gain(ifg, 0) self.src.set_bb_gain(bbg, 0) self.src.set_antenna('', 0) self.src.set_bandwidth(0, 0) self.connect((self.src, 0), (self, 0))
def __init__(self): gr.top_block.__init__(self, "Split 1") ################################################## # Variables ################################################## self.pilot_carriers = pilot_carriers = ((-27, -14, -7, 7, 14, 27),) self.pattern2 = pattern2 = [1, -1, 1, -1] self.pattern1 = pattern1 = [0., 1.41421356, 0., -1.41421356] self.occupied_carriers = occupied_carriers = (sorted(tuple(set([x for x in range(-26, 27)]) - set(pilot_carriers[0]) - set([0,]))),) self.fft_len = fft_len = 64 self.zcpu = zcpu = psutil self._xmlrpcport_config = ConfigParser.ConfigParser() self._xmlrpcport_config.read('default') try: xmlrpcport = self._xmlrpcport_config.getint("split1", "xmlrpcport") except: xmlrpcport = 8080 self.xmlrpcport = xmlrpcport self._usrpip_config = ConfigParser.ConfigParser() self._usrpip_config.read('./default') try: usrpip = self._usrpip_config.get("usrp_hydra", "ip") except: usrpip = "127.0.0.1" self.usrpip = usrpip self._timeout_config = ConfigParser.ConfigParser() self._timeout_config.read('./default') try: timeout = self._timeout_config.getint("global", "zmqtimeout") except: timeout = 100 self.timeout = timeout self.sync_word2 = sync_word2 = [0., 0., 0., 0., 0., 0.,] + pattern2 * ((fft_len-12)/len(pattern2)) +[0., 0., 0., 0., 0., 0.,] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0.,] + pattern1 * ((fft_len-12)/len(pattern1)) +[0., 0., 0., 0., 0., 0.,] self._rxport_config = ConfigParser.ConfigParser() self._rxport_config.read('./default') try: rxport = self._rxport_config.get("usrp_hydra", "rxport1") except: rxport = "2666" self.rxport = rxport self.rateRx = rateRx = 0 self.rate1 = rate1 = 0 self.rate0 = rate0 = 0 self.pilot_symbols = pilot_symbols = ((-1,1, 1, -1, -1, -1),) self._payloadport_config = ConfigParser.ConfigParser() self._payloadport_config.read('./default') try: payloadport = self._payloadport_config.get("split1", "payloadport") except: payloadport = "2101" self.payloadport = payloadport self.payload_mod = payload_mod = digital.constellation_bpsk() self._maxnoutput_config = ConfigParser.ConfigParser() self._maxnoutput_config.read('./default') try: maxnoutput = self._maxnoutput_config.getint("global", "maxnoutput") except: maxnoutput = 100 self.maxnoutput = maxnoutput self.iq_rxrate = iq_rxrate = 0 self._ip_config = ConfigParser.ConfigParser() self._ip_config.read('./default') try: ip = self._ip_config.get("split1", "ip") except: ip = "127.0.0.1" self.ip = ip self._headerport_config = ConfigParser.ConfigParser() self._headerport_config.read('./default') try: headerport = self._headerport_config.get("split1", "headerport") except: headerport = "2100" self.headerport = headerport self.header_mod = header_mod = digital.constellation_bpsk() self.hdr_format = hdr_format = digital.header_format_ofdm(occupied_carriers, 1, "packet_len",) self.cpu_percent = cpu_percent = 0 ################################################## # Blocks ################################################## self.probe1_1_0 = blocks.probe_rate(gr.sizeof_char*1, 500.0, 0.15) self.probe1_1 = blocks.probe_rate(gr.sizeof_char*1, 500.0, 0.15) self.probe1_0 = blocks.probe_rate(gr.sizeof_char*1, 500.0, 0.15) self.ziq_rxrate = blocks.probe_rate(gr.sizeof_gr_complex*1, 2000, 0.15) self.zeromq_push_sink_1 = zeromq.push_sink(gr.sizeof_char, 1, "tcp://" + ip + ":" + payloadport, timeout, True, -1) self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_char, 1, "tcp://" + ip + ":" + headerport, timeout, True, -1) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, "tcp://" + usrpip + ":" + rxport, 100, True, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('127.0.0.1', xmlrpcport), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() def _rateRx_probe(): while True: val = self.probe1_1_0.rate() try: self.set_rateRx(val) except AttributeError: pass time.sleep(1.0 / (10)) _rateRx_thread = threading.Thread(target=_rateRx_probe) _rateRx_thread.daemon = True _rateRx_thread.start() def _rate1_probe(): while True: val = self.probe1_1.rate() try: self.set_rate1(val) except AttributeError: pass time.sleep(1.0 / (10)) _rate1_thread = threading.Thread(target=_rate1_probe) _rate1_thread.daemon = True _rate1_thread.start() def _rate0_probe(): while True: val = self.probe1_0.rate() try: self.set_rate0(val) except AttributeError: pass time.sleep(1.0 / (10)) _rate0_thread = threading.Thread(target=_rate0_probe) _rate0_thread.daemon = True _rate0_thread.start() def _iq_rxrate_probe(): while True: val = self.ziq_rxrate.rate() try: self.set_iq_rxrate(val) except AttributeError: pass time.sleep(1.0 / (10)) _iq_rxrate_thread = threading.Thread(target=_iq_rxrate_probe) _iq_rxrate_thread.daemon = True _iq_rxrate_thread.start() self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, "packet_len") self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=16, frame_length_tag_key='frame_'+"packet_len", packet_length_tag_key="packet_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=1, debug_log=False, scramble_bits=False ) self.digital_crc32_bb_0 = digital.crc32_bb(False, "packet_len", True) def _cpu_percent_probe(): while True: val = self.zcpu.cpu_percent() try: self.set_cpu_percent(val) except AttributeError: pass time.sleep(1.0 / (1)) _cpu_percent_thread = threading.Thread(target=_cpu_percent_probe) _cpu_percent_thread.daemon = True _cpu_percent_thread.start() self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char*1, 200e3,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 200e3,True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, "RX'd Packets", ""); self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 100, "packet_len") self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, 1, "packet_len", False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), "packet_len", False, gr.GR_LSB_FIRST) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 100, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.probe1_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.probe1_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.zeromq_push_sink_1, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.probe1_1_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.ziq_rxrate, 0))
def __init__(self, fft_size=128): gr.top_block.__init__(self, "Holo RX") Qt.QWidget.__init__(self) self.setWindowTitle("Holo RX") 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", "holorx_host") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Parameters ################################################## self.fft_size = fft_size ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000 self.seconds_record = seconds_record = 7200 self.label_results_per_second = label_results_per_second = samp_rate / fft_size self.label_fftsize = label_fftsize = fft_size self.label_binwidth_hz = label_binwidth_hz = samp_rate / fft_size self.label_baseband_samp_freq = label_baseband_samp_freq = samp_rate self.gui_update_sec = gui_update_sec = 0.2 self.gain_rxb = gain_rxb = 0 self.gain_rxa = gain_rxa = 0 self.freq_rftune = freq_rftune = 70e6 self.client_address = client_address = "192.168.10.184" ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'RX 2 Channels') self.top_grid_layout.addWidget(self.tabs, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.zeromq_pull_source_1 = zeromq.pull_source( gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9998', 100, False, -1) self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9999', 100, False, -1) self.xmlrpc_client1 = xmlrpclib.Server('http://192.168.10.184:30000') self.xmlrpc_client0_0 = xmlrpclib.Server('http://192.168.10.184:30000') self.xmlrpc_client0 = xmlrpclib.Server('http://192.168.10.184:30000') self.to_mag_db_0_3 = to_mag_db() self.to_mag_db_0_1 = to_mag_db() self.to_mag_db_0_0 = to_mag_db() self.qtgui_number_sink_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 2) self.qtgui_number_sink_0_0_0.set_update_time(gui_update_sec) self.qtgui_number_sink_0_0_0.set_title('Difference A-B') labels = [ 'Magnitude (dB)', 'Phase (deg)', 'A - B', '', '', '', '', '', '', '' ] units = ['dB', 'degrees', 'dB', '', '', '', '', '', '', ''] 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(2): self.qtgui_number_sink_0_0_0.set_min(i, -1) self.qtgui_number_sink_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_number_sink_0_0_0_win, 3, 1, 2, 1) for r in range(3, 5): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 2) self.qtgui_number_sink_0_0.set_update_time(gui_update_sec) self.qtgui_number_sink_0_0.set_title('Magnitude (dB)') labels = ['RXA', 'RXB', 'RXB', '', '', '', '', '', '', ''] units = ['dB', 'dB', 'dB', '', '', '', '', '', '', ''] 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(2): self.qtgui_number_sink_0_0.set_min(i, -1) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_number_sink_0_0_win, 1, 1, 2, 1) for r in range(1, 3): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_size, #size firdes.WIN_HANN, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(gui_update_sec) self.qtgui_freq_sink_x_0.set_y_axis(-160, 0) self.qtgui_freq_sink_x_0.set_y_label('FFT Amplitude', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(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 = ['RXA', 'RXB', 'RXB', '', '', '', '', '', '', ''] widths = [1, 1, 2, 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(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 2) for r in range(0, 1): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(0, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self._label_results_per_second_tool_bar = Qt.QToolBar(self) if None: self._label_results_per_second_formatter = None else: self._label_results_per_second_formatter = lambda x: eng_notation.num_to_str( x) self._label_results_per_second_tool_bar.addWidget( Qt.QLabel('FFT Results Per Second ' + ": ")) self._label_results_per_second_label = Qt.QLabel( str( self._label_results_per_second_formatter( self.label_results_per_second))) self._label_results_per_second_tool_bar.addWidget( self._label_results_per_second_label) self.top_grid_layout.addWidget(self._label_results_per_second_tool_bar, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._label_fftsize_tool_bar = Qt.QToolBar(self) if None: self._label_fftsize_formatter = None else: self._label_fftsize_formatter = lambda x: str(x) self._label_fftsize_tool_bar.addWidget(Qt.QLabel('FFT Size' + ": ")) self._label_fftsize_label = Qt.QLabel( str(self._label_fftsize_formatter(self.label_fftsize))) self._label_fftsize_tool_bar.addWidget(self._label_fftsize_label) self.top_grid_layout.addWidget(self._label_fftsize_tool_bar, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._label_binwidth_hz_tool_bar = Qt.QToolBar(self) if None: self._label_binwidth_hz_formatter = None else: self._label_binwidth_hz_formatter = lambda x: eng_notation.num_to_str( x) self._label_binwidth_hz_tool_bar.addWidget( Qt.QLabel('FFT Bin Width (Hz) ' + ": ")) self._label_binwidth_hz_label = Qt.QLabel( str(self._label_binwidth_hz_formatter(self.label_binwidth_hz))) self._label_binwidth_hz_tool_bar.addWidget( self._label_binwidth_hz_label) self.top_grid_layout.addWidget(self._label_binwidth_hz_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._label_baseband_samp_freq_tool_bar = Qt.QToolBar(self) if None: self._label_baseband_samp_freq_formatter = None else: self._label_baseband_samp_freq_formatter = lambda x: eng_notation.num_to_str( x) self._label_baseband_samp_freq_tool_bar.addWidget( Qt.QLabel('Baseband Sample Frequency (Hz)' + ": ")) self._label_baseband_samp_freq_label = Qt.QLabel( str( self._label_baseband_samp_freq_formatter( self.label_baseband_samp_freq))) self._label_baseband_samp_freq_tool_bar.addWidget( self._label_baseband_samp_freq_label) self.top_grid_layout.addWidget(self._label_baseband_samp_freq_tool_bar, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._gain_rxb_range = Range(0, 80, 1, 0, 1) self._gain_rxb_win = RangeWidget(self._gain_rxb_range, self.set_gain_rxb, 'Gain RXB', "counter", float) self.tabs_grid_layout_0.addWidget(self._gain_rxb_win, 2, 0, 1, 1) for r in range(2, 3): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tabs_grid_layout_0.setColumnStretch(c, 1) self._gain_rxa_range = Range(0, 80, 1, 0, 1) self._gain_rxa_win = RangeWidget(self._gain_rxa_range, self.set_gain_rxa, 'Gain RXA', "counter", float) self.tabs_grid_layout_0.addWidget(self._gain_rxa_win, 1, 0, 1, 1) for r in range(1, 2): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tabs_grid_layout_0.setColumnStretch(c, 1) self._freq_rftune_range = Range(10e6, 6e9, 1, 70e6, 1) self._freq_rftune_win = RangeWidget(self._freq_rftune_range, self.set_freq_rftune, 'Freq RF Tune', "counter", float) self.tabs_grid_layout_0.addWidget(self._freq_rftune_win, 3, 0, 1, 1) for r in range(3, 4): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.fft_bin_select_B = fft_bin_select( fft_size=fft_size, nskip=1, ) self.fft_bin_select_A = fft_bin_select( fft_size=fft_size, nskip=1, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (180 / np.pi, )) self.blocks_head_0 = blocks.head( gr.sizeof_gr_complex * 1, int(seconds_record * samp_rate / fft_size)) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, 'test2hrs.iq', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.to_mag_db_0_3, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_0_0_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fft_bin_select_A, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.fft_bin_select_A, 0), (self.to_mag_db_0_0, 0)) self.connect((self.fft_bin_select_B, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.fft_bin_select_B, 0), (self.to_mag_db_0_1, 0)) self.connect((self.to_mag_db_0_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.to_mag_db_0_1, 0), (self.qtgui_number_sink_0_0, 1)) self.connect((self.to_mag_db_0_3, 0), (self.qtgui_number_sink_0_0_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.fft_bin_select_B, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.zeromq_pull_source_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.zeromq_pull_source_1, 0), (self.fft_bin_select_A, 0))
def __init__(self, maxoutbuffer=0): gr.top_block.__init__(self, "Split 3") ################################################## # Parameters ################################################## self.maxoutbuffer = maxoutbuffer ################################################## # Variables ################################################## self.pilot_carriers = pilot_carriers = ((-27, -14, -7, 7, 14, 27), ) self.pattern2 = pattern2 = [1, -1, 1, -1] self.pattern1 = pattern1 = [0., 1.41421356, 0., -1.41421356] self.fft_len = fft_len = 64 self.zcpu = zcpu = psutil self._xmlrpcport_config = ConfigParser.ConfigParser() self._xmlrpcport_config.read('default') try: xmlrpcport = self._xmlrpcport_config.getint("split3", 'xmlrpcport') except: xmlrpcport = 8081 self.xmlrpcport = xmlrpcport self._timeout_config = ConfigParser.ConfigParser() self._timeout_config.read('default') try: timeout = self._timeout_config.getint("global", "zmqtimeout") except: timeout = 100 self.timeout = timeout self.sync_word2 = sync_word2 = [ 0., 0., 0., 0., 0., 0., ] + pattern2 * ((fft_len - 12) / len(pattern2)) + [ 0., 0., 0., 0., 0., 0., ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., ] + pattern1 * ((fft_len - 12) / len(pattern1)) + [ 0., 0., 0., 0., 0., 0., ] self._split2port_config = ConfigParser.ConfigParser() self._split2port_config.read('default') try: split2port = self._split2port_config.get("split2", "port") except: split2port = "2200" self.split2port = split2port self._split2ip_config = ConfigParser.ConfigParser() self._split2ip_config.read('default') try: split2ip = self._split2ip_config.get("split2", "ip") except: split2ip = "127.0.0.1" self.split2ip = split2ip self.rate = rate = 0 self._port_config = ConfigParser.ConfigParser() self._port_config.read('default') try: port = self._port_config.get("split3", "port") except: port = "2300" self.port = port self.pilot_symbols = pilot_symbols = ((-1, 1, 1, -1, -1, -1), ) self.occupied_carriers = occupied_carriers = (sorted( tuple( set([x for x in range(-26, 27)]) - set(pilot_carriers[0]) - set([ 0, ]))), ) self._maxnoutput_config = ConfigParser.ConfigParser() self._maxnoutput_config.read('default') try: maxnoutput = self._maxnoutput_config.getint("global", "maxnoutput") except: maxnoutput = 100 self.maxnoutput = maxnoutput self._ip_config = ConfigParser.ConfigParser() self._ip_config.read('default') try: ip = self._ip_config.get("split3", "ip") except: ip = "127.0.0.1" self.ip = ip self.cpu_percent = cpu_percent = 0 ################################################## # Blocks ################################################## self.probe3 = blocks.probe_rate(gr.sizeof_gr_complex * 1, 2000, 0.15) self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://" + ip + ":" + port, timeout, True, -1) self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, "tcp://" + split2ip + ":" + split2port, timeout, True, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ('127.0.0.1', xmlrpcport), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread( target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() def _rate_probe(): while True: val = self.probe3.rate() try: self.set_rate(val) except AttributeError: pass time.sleep(1.0 / (10)) _rate_thread = threading.Thread(target=_rate_probe) _rate_thread.daemon = True _rate_thread.start() self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + 16, 0, "packet_len") self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), "packet_len") def _cpu_percent_probe(): while True: val = self.zcpu.cpu_percent() try: self.set_cpu_percent(val) except AttributeError: pass time.sleep(1.0 / (1)) _cpu_percent_thread = threading.Thread(target=_cpu_percent_probe) _cpu_percent_thread.daemon = True _cpu_percent_thread.start() self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex * 1, '', "") self.blocks_tag_debug_0.set_display(True) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.probe3, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Split 2") ################################################## # Variables ################################################## self.zcpu = zcpu = psutil self._xmlrpcport_config = ConfigParser.ConfigParser() self._xmlrpcport_config.read('default') try: xmlrpcport = self._xmlrpcport_config.getint("split2", "xmlrpcport") except: xmlrpcport = 8080 self.xmlrpcport = xmlrpcport self._timeout_config = ConfigParser.ConfigParser() self._timeout_config.read('./default') try: timeout = self._timeout_config.getint("global", "zmqtimeout") except: timeout = 100 self.timeout = timeout self._split1ip_config = ConfigParser.ConfigParser() self._split1ip_config.read('./default') try: split1ip = self._split1ip_config.get("split1", "ip") except: split1ip = "127.0.0.1" self.split1ip = split1ip self.rate = rate = 0 self._port_config = ConfigParser.ConfigParser() self._port_config.read('./default') try: port = self._port_config.get("split2", "port") except: port = '2200' self.port = port self._payloadport_config = ConfigParser.ConfigParser() self._payloadport_config.read('./default') try: payloadport = self._payloadport_config.get("split1", "payloadport") except: payloadport = "2101" self.payloadport = payloadport self.payload_mod = payload_mod = digital.constellation_bpsk() self._maxnoutput_config = ConfigParser.ConfigParser() self._maxnoutput_config.read('./default') try: maxnoutput = self._maxnoutput_config.getint("global", "maxnoutput") except: maxnoutput = 100 self.maxnoutput = maxnoutput self._ip_config = ConfigParser.ConfigParser() self._ip_config.read('./default') try: ip = self._ip_config.get("split2", "ip") except: ip = "127.0.0.1" self.ip = ip self._headerport_config = ConfigParser.ConfigParser() self._headerport_config.read('./default') try: headerport = self._headerport_config.get("split1", "headerport") except: headerport = "2100" self.headerport = headerport self.header_mod = header_mod = digital.constellation_bpsk() self.cpu_percent = cpu_percent = 0 ################################################## # Blocks ################################################## self.probe2 = blocks.probe_rate(gr.sizeof_gr_complex*1, 2000, 0.15) self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://" + ip + ":" + port, timeout, True, -1) self.zeromq_pull_source_1 = zeromq.pull_source(gr.sizeof_char, 1, "tcp://" + split1ip + ":" + payloadport, timeout, True, -1) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_char, 1, "tcp://" + split1ip + ":" + headerport, timeout, True, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('127.0.0.1', xmlrpcport), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() def _rate_probe(): while True: val = self.probe2.rate() try: self.set_rate(val) except AttributeError: pass time.sleep(1.0 / (10)) _rate_thread = threading.Thread(target=_rate_probe) _rate_thread.daemon = True _rate_thread.start() self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((payload_mod.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((header_mod.points()), 1) def _cpu_percent_probe(): while True: val = self.zcpu.cpu_percent() try: self.set_cpu_percent(val) except AttributeError: pass time.sleep(1.0 / (1)) _cpu_percent_thread = threading.Thread(target=_cpu_percent_probe) _cpu_percent_thread.daemon = True _cpu_percent_thread.start() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, 1e6,True) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, "packet_len", 0) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex*1, '', ""); self.blocks_tag_debug_0.set_display(True) ################################################## # Connections ################################################## self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.probe2, 0)) self.connect((self.blocks_throttle_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.zeromq_pull_source_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.zeromq_pull_source_1, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "usrp") ################################################## # Variables ################################################## self._xmlrpcport_config = ConfigParser.ConfigParser() self._xmlrpcport_config.read('./default') try: xmlrpcport = self._xmlrpcport_config.getint("usrp", 'xmlrpcport') except: xmlrpcport = 8081 self.xmlrpcport = xmlrpcport self.txrate = txrate = 0 self._txoutport_config = ConfigParser.ConfigParser() self._txoutport_config.read('./default') try: txoutport = self._txoutport_config.get("usrp", "txoutport") except: txoutport = "2666" self.txoutport = txoutport self._txgain_config = ConfigParser.ConfigParser() self._txgain_config.read('./default') try: txgain = self._txgain_config.getfloat("usrp", "txgain") except: txgain = 0.9 self.txgain = txgain self._txfreq_config = ConfigParser.ConfigParser() self._txfreq_config.read('./default') try: txfreq = self._txfreq_config.getfloat("usrp", "txfreq1") except: txfreq = 949.45e6 self.txfreq = txfreq self._timeout_config = ConfigParser.ConfigParser() self._timeout_config.read('./default') try: timeout = self._timeout_config.getint("global", "zmqtimeout") except: timeout = 100 self.timeout = timeout self._samprate_config = ConfigParser.ConfigParser() self._samprate_config.read('./default') try: samprate = self._samprate_config.getfloat("usrp", "samprate1") except: samprate = 500e3 self.samprate = samprate self._rxport_config = ConfigParser.ConfigParser() self._rxport_config.read('./default') try: rxport = self._rxport_config.get("rx", "port") except: rxport = "2300" self.rxport = rxport self._rxoutport_config = ConfigParser.ConfigParser() self._rxoutport_config.read('./default') try: rxoutport = self._rxoutport_config.get("usrp", "rxoutport") except: rxoutport = "2666" self.rxoutport = rxoutport self._rxip_config = ConfigParser.ConfigParser() self._rxip_config.read('./default') try: rxip = self._rxip_config.get("rx", "ip") except: rxip = "127.0.0.1" self.rxip = rxip self._rxgain_config = ConfigParser.ConfigParser() self._rxgain_config.read('./default') try: rxgain = self._rxgain_config.getfloat("usrp", "rxgain") except: rxgain = 0.9 self.rxgain = rxgain self._rxfreq_config = ConfigParser.ConfigParser() self._rxfreq_config.read('./default') try: rxfreq = self._rxfreq_config.getfloat("usrp", "rxfreq1") except: rxfreq = 4.4e9 self.rxfreq = rxfreq self._maxnoutput_config = ConfigParser.ConfigParser() self._maxnoutput_config.read('./default') try: maxnoutput = self._maxnoutput_config.getint("global", "maxnoutput") except: maxnoutput = 100 self.maxnoutput = maxnoutput self._ip_config = ConfigParser.ConfigParser() self._ip_config.read('./default') try: ip = self._ip_config.get("usrp", "ip") except: ip = "192.168.10.104" self.ip = ip self._finalsplitport_config = ConfigParser.ConfigParser() self._finalsplitport_config.read('./default') try: finalsplitport = self._finalsplitport_config.get( "usrp", "finalsplitport") except: finalsplitport = "2300" self.finalsplitport = finalsplitport self._finalsplitip_config = ConfigParser.ConfigParser() self._finalsplitip_config.read('./default') try: finalsplitip = self._finalsplitip_config.get( "usrp", "finalsplitip") except: finalsplitip = "192.168.10.23" self.finalsplitip = finalsplitip self._amplitude_config = ConfigParser.ConfigParser() self._amplitude_config.read('./default') try: amplitude = self._amplitude_config.getfloat("usrp", "amplitude1") except: amplitude = 0.01 self.amplitude = amplitude ################################################## # Blocks ################################################## self.ztxrate = blocks.probe_rate(gr.sizeof_gr_complex * 1, 2000, 0.15) self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, "tcp://" + finalsplitip + ":" + finalsplitport, timeout, True, -1) self.xmlrpc_server_0_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( (ip, xmlrpcport), allow_none=True) self.xmlrpc_server_0_0.register_instance(self) self.xmlrpc_server_0_0_thread = threading.Thread( target=self.xmlrpc_server_0_0.serve_forever) self.xmlrpc_server_0_0_thread.daemon = True self.xmlrpc_server_0_0_thread.start() self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samprate) self.uhd_usrp_sink_0.set_center_freq(txfreq, 0) self.uhd_usrp_sink_0.set_normalized_gain(txgain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(samprate, 0) def _txrate_probe(): while True: val = self.ztxrate.rate() try: self.set_txrate(val) except AttributeError: pass time.sleep(1.0 / (10)) _txrate_thread = threading.Thread(target=_txrate_probe) _txrate_thread.daemon = True _txrate_thread.start() self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex * 1, "Tx'd Packet", "") self.blocks_tag_debug_0.set_display(True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (amplitude, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.ztxrate, 0))
def __init__(self, MTU=10000, bw=100e3, frequency_rx=2.4505e9 + 1e6, frequency_tx=2.4505e9, ip_pub='tcp://192.168.5.134:7001', ip_sub='tcp://192.168.5.109:7000', offset=-250e3): gr.top_block.__init__(self, "Lora Side1") ################################################## # Parameters ################################################## self.MTU = MTU self.bw = bw self.frequency_rx = frequency_rx self.frequency_tx = frequency_tx self.ip_pub = ip_pub self.ip_sub = ip_sub self.offset = offset ################################################## # Variables ################################################## self.rep = rep = 3 self.spreading_factor = spreading_factor = 8 self.samp_rate = samp_rate = 500e3 self.ldr = ldr = True self.header = header = False self.enc_rep = enc_rep = fec.repetition_encoder_make(480, rep) self.enc_dummy = enc_dummy = fec.dummy_encoder_make(MTU*8) self.enc_ccsds = enc_ccsds = fec.ccsds_encoder_make(MTU*8, 0, fec.CC_TERMINATED) self.dec_rep = dec_rep = fec.repetition_decoder.make(480, rep, 0.5) self.dec_dummy = dec_dummy = fec.dummy_decoder.make(MTU*8) self.dec_cc = dec_cc = fec.cc_decoder.make(8000, 7, 2, ([109,79]), 0, -1, fec.CC_TERMINATED, False) self.code_rate = code_rate = 4 ################################################## # Blocks ################################################## self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, ip_pub, 100, False, -1) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, ip_sub, 100, False, -1) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( bw/samp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samp_rate/bw, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.lora_mod_0 = lora.mod(spreading_factor, 0x12) self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr, header) self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2) self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr, header) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tap0', MTU, False) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.lora_encode_0, 'in')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.lora_decode_0, 'out'), (self.blocks_tuntap_pdu_0, 'pdus')) self.msg_connect((self.lora_demod_0, 'out'), (self.lora_decode_0, 'in')) self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in')) self.connect((self.lora_mod_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.lora_demod_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Path Length Difference") Qt.QWidget.__init__(self) self.setWindowTitle("Path Length Difference") 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", "demo_length_host") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.velocity_factor = velocity_factor = 0.69 self.speed_of_light = speed_of_light = 299792458 self.rf_freq = rf_freq = 100e6 self.wavelength = wavelength = velocity_factor * speed_of_light / rf_freq self.wave_number = wave_number = 2 * np.pi / wavelength self.meters_per_radian = meters_per_radian = 1 / wave_number self.variable_qtgui_label_3 = variable_qtgui_label_3 = rf_freq / 1e6 self.variable_qtgui_label_2 = variable_qtgui_label_2 = meters_per_radian self.variable_qtgui_label_1 = variable_qtgui_label_1 = wavelength self.variable_qtgui_label_0 = variable_qtgui_label_0 = velocity_factor self.tx_gain = tx_gain = 30 self.samp_rate = samp_rate = 100e3 self.rx_gain = rx_gain = 30 self.gui_update_sec = gui_update_sec = 0.2 self.fft_size = fft_size = 64 self.client_address = client_address = "192.168.10.184" ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'Magnitude') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'Phase') self.top_grid_layout.addWidget(self.tabs, 0, 0, 1, 2) self.zeromq_pull_source_2 = zeromq.pull_source( gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9997', 100, False, -1) self.zeromq_pull_source_1 = zeromq.pull_source( gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9998', 100, False, -1) self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, 'tcp://192.168.10.184:9999', 100, False, -1) self.xmlrpc_client1 = xmlrpclib.Server('http://192.168.10.184:30000') self.xmlrpc_client0 = xmlrpclib.Server('http://192.168.10.184:30000') self._variable_qtgui_label_3_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_3_formatter = None else: self._variable_qtgui_label_3_formatter = lambda x: x self._variable_qtgui_label_3_tool_bar.addWidget( Qt.QLabel('RF Frequency (MHz)' + ": ")) self._variable_qtgui_label_3_label = Qt.QLabel( str( self._variable_qtgui_label_3_formatter( self.variable_qtgui_label_3))) self._variable_qtgui_label_3_tool_bar.addWidget( self._variable_qtgui_label_3_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_3_tool_bar, 1, 0, 1, 1) self._variable_qtgui_label_2_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_2_formatter = None else: self._variable_qtgui_label_2_formatter = lambda x: x self._variable_qtgui_label_2_tool_bar.addWidget( Qt.QLabel('Meters Per Radian of Phase in Cable' + ": ")) self._variable_qtgui_label_2_label = Qt.QLabel( str( self._variable_qtgui_label_2_formatter( self.variable_qtgui_label_2))) self._variable_qtgui_label_2_tool_bar.addWidget( self._variable_qtgui_label_2_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_2_tool_bar, 4, 0, 1, 1) self._variable_qtgui_label_1_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_1_formatter = None else: self._variable_qtgui_label_1_formatter = lambda x: x self._variable_qtgui_label_1_tool_bar.addWidget( Qt.QLabel('Wavelength in Cable (m)' + ": ")) self._variable_qtgui_label_1_label = Qt.QLabel( str( self._variable_qtgui_label_1_formatter( self.variable_qtgui_label_1))) self._variable_qtgui_label_1_tool_bar.addWidget( self._variable_qtgui_label_1_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_1_tool_bar, 3, 0, 1, 1) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel('Velocity Factor of Cable' + ": ")) 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, 2, 0, 1, 1) self._tx_gain_range = Range(0, 40, 1, 30, 50) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain', "counter_slider", float) self.tabs_grid_layout_0.addWidget(self._tx_gain_win, 1, 0, 1, 1) self.to_mag_db_0_4 = to_mag_db() self.to_mag_db_0_3 = to_mag_db() self.to_mag_db_0_2 = to_mag_db() self.to_mag_db_0_1 = to_mag_db() self.to_mag_db_0_0 = to_mag_db() self.to_mag_db_0 = to_mag_db() self._rx_gain_range = Range(0, 30, 1, 30, 100) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.tabs_grid_layout_0.addWidget(self._rx_gain_win, 1, 1, 1, 1) self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 3) self.qtgui_number_sink_1.set_update_time(gui_update_sec) self.qtgui_number_sink_1.set_title("Length (m)") labels = ['REF - A', 'REF - B', 'A - B', '', '', '', '', '', '', ''] units = ['m', 'm', 'm', '', '', '', '', '', '', ''] 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(3): 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.tabs_grid_layout_1.addWidget(self._qtgui_number_sink_1_win, 2, 0, 1, 1) self.qtgui_number_sink_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 3) self.qtgui_number_sink_0_0_0.set_update_time(gui_update_sec) self.qtgui_number_sink_0_0_0.set_title("Magnitude Difference (dB)") labels = ['REF - A', 'REF - B', 'A - B', '', '', '', '', '', '', ''] units = ['dB', 'dB', 'dB', '', '', '', '', '', '', ''] 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(3): self.qtgui_number_sink_0_0_0.set_min(i, -1) self.qtgui_number_sink_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_number_sink_0_0_0_win, 4, 0, 1, 2) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 3) self.qtgui_number_sink_0_0.set_update_time(gui_update_sec) self.qtgui_number_sink_0_0.set_title("Magnitude (dB)") labels = ['REF', 'RXA', 'RXB', '', '', '', '', '', '', ''] units = ['dB', 'dB', 'dB', '', '', '', '', '', '', ''] 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(3): self.qtgui_number_sink_0_0.set_min(i, -1) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_number_sink_0_0_win, 3, 0, 1, 2) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 3) self.qtgui_number_sink_0.set_update_time(gui_update_sec) self.qtgui_number_sink_0.set_title("Phase Difference (rad)") labels = ['REF - A', 'REF - B', 'A - B', '', '', '', '', '', '', ''] units = ['rad', 'rad', 'rad', '', '', '', '', '', '', ''] 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(3): 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.tabs_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 1, 0, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_HANN, #wintype rf_freq, #fc samp_rate, #bw "", #name 3 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(gui_update_sec) self.qtgui_freq_sink_x_0.set_y_axis(-140, -20) self.qtgui_freq_sink_x_0.set_y_label('Amplitude', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(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 = ['REF', 'RXA', 'RXB', '', '', '', '', '', '', ''] widths = [1, 2, 2, 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(3): 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.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 2) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 3 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(gui_update_sec) self.qtgui_const_sink_x_0.set_y_axis(-4, 4) self.qtgui_const_sink_x_0.set_x_axis(-4, 4) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['REF - A', 'REF - B', 'A - B', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_1.addWidget(self._qtgui_const_sink_x_0_win, 0, 0, 1, 1) self.fft_bin_select_ref = fft_bin_select( fft_size=64, nskip=1, ) self.fft_bin_select_B = fft_bin_select( fft_size=64, nskip=1, ) self.fft_bin_select_A = fft_bin_select( fft_size=64, nskip=1, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vff( (meters_per_radian, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff( (meters_per_radian, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff( (meters_per_radian, )) self.blocks_divide_ref_b = blocks.divide_cc(1) self.blocks_divide_ref_a = blocks.divide_cc(1) self.blocks_divide_a_b = blocks.divide_cc(1) self.blocks_complex_to_arg_0_1 = blocks.complex_to_arg(1) self.blocks_complex_to_arg_0_0 = blocks.complex_to_arg(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_const_vxx_0_1 = blocks.add_const_vff((np.pi, )) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((np.pi, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((np.pi, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_add_const_vxx_0_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_add_const_vxx_0_1, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_complex_to_arg_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_complex_to_arg_0_0, 0), (self.qtgui_number_sink_0, 2)) self.connect((self.blocks_complex_to_arg_0_1, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_complex_to_arg_0_1, 0), (self.qtgui_number_sink_0, 1)) self.connect((self.blocks_divide_a_b, 0), (self.blocks_complex_to_arg_0_0, 0)) self.connect((self.blocks_divide_a_b, 0), (self.qtgui_const_sink_x_0, 2)) self.connect((self.blocks_divide_a_b, 0), (self.to_mag_db_0_4, 0)) self.connect((self.blocks_divide_ref_a, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_divide_ref_a, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_divide_ref_a, 0), (self.to_mag_db_0_3, 0)) self.connect((self.blocks_divide_ref_b, 0), (self.blocks_complex_to_arg_0_1, 0)) self.connect((self.blocks_divide_ref_b, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.blocks_divide_ref_b, 0), (self.to_mag_db_0_2, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_number_sink_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_number_sink_1, 1)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.qtgui_number_sink_1, 2)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fft_bin_select_A, 0), (self.blocks_divide_a_b, 0)) self.connect((self.fft_bin_select_A, 0), (self.blocks_divide_ref_a, 1)) self.connect((self.fft_bin_select_A, 0), (self.to_mag_db_0_0, 0)) self.connect((self.fft_bin_select_B, 0), (self.blocks_divide_a_b, 1)) self.connect((self.fft_bin_select_B, 0), (self.blocks_divide_ref_b, 1)) self.connect((self.fft_bin_select_B, 0), (self.to_mag_db_0_1, 0)) self.connect((self.fft_bin_select_ref, 0), (self.blocks_divide_ref_a, 0)) self.connect((self.fft_bin_select_ref, 0), (self.blocks_divide_ref_b, 0)) self.connect((self.fft_bin_select_ref, 0), (self.to_mag_db_0, 0)) self.connect((self.to_mag_db_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.to_mag_db_0_0, 0), (self.qtgui_number_sink_0_0, 1)) self.connect((self.to_mag_db_0_1, 0), (self.qtgui_number_sink_0_0, 2)) self.connect((self.to_mag_db_0_2, 0), (self.qtgui_number_sink_0_0_0, 1)) self.connect((self.to_mag_db_0_3, 0), (self.qtgui_number_sink_0_0_0, 0)) self.connect((self.to_mag_db_0_4, 0), (self.qtgui_number_sink_0_0_0, 2)) self.connect((self.zeromq_pull_source_0, 0), (self.fft_bin_select_B, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.qtgui_freq_sink_x_0, 2)) self.connect((self.zeromq_pull_source_1, 0), (self.fft_bin_select_A, 0)) self.connect((self.zeromq_pull_source_1, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.zeromq_pull_source_2, 0), (self.blocks_throttle_0, 0)) self.connect((self.zeromq_pull_source_2, 0), (self.fft_bin_select_ref, 0))
def __init__(self): gr.top_block.__init__(self, "VR2 TX all-in-one") ################################################## # Variables ################################################## self.pilot_carriers = pilot_carriers = ((-14, -7, 7, 14), ) self.pattern2 = pattern2 = [1, -1, 1, -1] self.pattern1 = pattern1 = [0., 1.41421356, 0., -1.41421356] self.fft_len = fft_len = 64 self.zcpu = zcpu = psutil self._xmlrpcport_config = ConfigParser.ConfigParser() self._xmlrpcport_config.read('default') try: xmlrpcport = self._xmlrpcport_config.getint("vr2_tx", 'xmlrpcport') except: xmlrpcport = 8081 self.xmlrpcport = xmlrpcport self._usrpip_config = ConfigParser.ConfigParser() self._usrpip_config.read('./default') try: usrpip = self._usrpip_config.get("usrp_hydra", "ip") except: usrpip = "127.0.0.1" self.usrpip = usrpip self._txoutport_config = ConfigParser.ConfigParser() self._txoutport_config.read('./default') try: txoutport = self._txoutport_config.get("vr2_tx", "port") except: txoutport = "2666" self.txoutport = txoutport self.tx_iq_rate = tx_iq_rate = 0 self.tx_goodput = tx_goodput = 0 self.sync_word2 = sync_word2 = [ 0., 0., 0., 0., 0., 0., ] + pattern2 * ((fft_len - 12) / len(pattern2)) + [ 0., 0., 0., 0., 0., 0., ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., ] + pattern1 * ((fft_len - 12) / len(pattern1)) + [ 0., 0., 0., 0., 0., 0., ] self._samprate_config = ConfigParser.ConfigParser() self._samprate_config.read('./default') try: samprate = self._samprate_config.getfloat("usrp_hydra", "samprate2") except: samprate = 0 self.samprate = samprate self._rxport_config = ConfigParser.ConfigParser() self._rxport_config.read('./default') try: rxport = self._rxport_config.get("usrp_hydra", "rxport2") except: rxport = "2302" self.rxport = rxport self.rx_goodput = rx_goodput = 0 self.pilot_symbols = pilot_symbols = ((1, 1, -1, -1), ) self.packet_len = packet_len = 100 self.occupied_carriers = occupied_carriers = (sorted( tuple( set([x for x in range(-26, 27)]) - set(pilot_carriers[0]) - set([ 0, ]))), ) self.iq_rxrate = iq_rxrate = 0 self._ip_config = ConfigParser.ConfigParser() self._ip_config.read('./default') try: ip = self._ip_config.get("vr2_tx", "ip") except: ip = "127.0.0.1" self.ip = ip self.cpu_percent = cpu_percent = 0 ################################################## # Blocks ################################################## self.ztxrate = blocks.probe_rate(gr.sizeof_char * 1, 2000, 0.15) self.ztxiqrate = blocks.probe_rate(gr.sizeof_gr_complex * 1, 2000, 0.15) self.zrxrate = blocks.probe_rate(gr.sizeof_char * 1, 2000, 0.15) self.ziq_rxrate = blocks.probe_rate(gr.sizeof_gr_complex * 1, 2000, 0.15) self.zeromq_push_sink_0 = zeromq.push_sink( gr.sizeof_gr_complex, 1, "tcp://" + ip + ":" + txoutport, 100, True, -1) self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, "tcp://" + usrpip + ":" + rxport, 100, True, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ('127.0.0.1', xmlrpcport), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread( target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() def _tx_iq_rate_probe(): while True: val = self.ztxiqrate.rate() try: self.set_tx_iq_rate(val) except AttributeError: pass time.sleep(1.0 / (10)) _tx_iq_rate_thread = threading.Thread(target=_tx_iq_rate_probe) _tx_iq_rate_thread.daemon = True _tx_iq_rate_thread.start() def _tx_goodput_probe(): while True: val = self.ztxrate.rate() try: self.set_tx_goodput(val) except AttributeError: pass time.sleep(1.0 / (10)) _tx_goodput_thread = threading.Thread(target=_tx_goodput_probe) _tx_goodput_thread.daemon = True _tx_goodput_thread.start() def _rx_goodput_probe(): while True: val = self.zrxrate.rate() try: self.set_rx_goodput(val) except AttributeError: pass time.sleep(1.0 / (10)) _rx_goodput_thread = threading.Thread(target=_rx_goodput_probe) _rx_goodput_thread.daemon = True _rx_goodput_thread.start() def _iq_rxrate_probe(): while True: val = self.ziq_rxrate.rate() try: self.set_iq_rxrate(val) except AttributeError: pass time.sleep(1.0 / (10)) _iq_rxrate_thread = threading.Thread(target=_iq_rxrate_probe) _iq_rxrate_thread.daemon = True _iq_rxrate_thread.start() self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=16, packet_length_tag_key="packet_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=1, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=64, cp_len=16, frame_length_tag_key='frame_' + "packet_len", packet_length_tag_key="packet_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=1, debug_log=False, scramble_bits=False) def _cpu_percent_probe(): while True: val = self.zcpu.cpu_percent() try: self.set_cpu_percent(val) except AttributeError: pass time.sleep(1.0 / (1)) _cpu_percent_thread = threading.Thread(target=_cpu_percent_probe) _cpu_percent_thread.daemon = True _cpu_percent_thread.start() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, 200e3, True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, "RX'd Packet", "") self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, "packet_len") self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(5, 10, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.ztxrate, 0)) self.connect((self.blocks_throttle_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.ztxiqrate, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.zrxrate, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.ziq_rxrate, 0))
def __init__(self): gr.top_block.__init__( self, "TJ Cubesat Parameter Control (no GUI with IQ Streaming)") Qt.QWidget.__init__(self) self.setWindowTitle( "TJ Cubesat Parameter Control (no GUI with IQ Streaming)") 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", "TJ_cubesat_param_cntrl_for_no_gui_with_IQ_streaming") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.freq_chooser = freq_chooser = 144.39e6 self.xml_rpc_port = xml_rpc_port = 5550 self.tx_gain = tx_gain = 10 self.rf_rx_rate = rf_rx_rate = 192000 self.gain = gain = 40 self.freq = freq = freq_chooser self.cubesat_zmq_port_4 = cubesat_zmq_port_4 = "5504" self.cubesat_zmq_port_3 = cubesat_zmq_port_3 = "5503" self.cubesat_zmq_port_2 = cubesat_zmq_port_2 = "5502" self.cubesat_zmq_port_1 = cubesat_zmq_port_1 = "5501" self.cubesat_ip_addr = cubesat_ip_addr = "192.168.1.10" self.audio_rate = audio_rate = 48000 self.audio_line_driver = audio_line_driver = 0.8 ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'Big Picture') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'CUBESAT TX/RX') self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, 'GND STAT TX/RX') self.tabs_widget_3 = Qt.QWidget() self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3) self.tabs_grid_layout_3 = Qt.QGridLayout() self.tabs_layout_3.addLayout(self.tabs_grid_layout_3) self.tabs.addTab(self.tabs_widget_3, 'MOD/DEMOD') self.top_grid_layout.addWidget(self.tabs, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.zeromq_pull_source_0_0_0_0 = zeromq.pull_source( gr.sizeof_float, 1, "tcp://" + cubesat_ip_addr + ":" + cubesat_zmq_port_4, 100, False, -1) self.zeromq_pull_source_0_0_0 = zeromq.pull_source( gr.sizeof_float, 1, "tcp://" + cubesat_ip_addr + ":" + cubesat_zmq_port_3, 100, False, -1) self.zeromq_pull_source_0_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, "tcp://" + cubesat_ip_addr + ":" + cubesat_zmq_port_2, 100, False, -1) self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, "tcp://" + cubesat_ip_addr + ":" + cubesat_zmq_port_1, 100, False, -1) self.xmlrpc_client1_1 = xmlrpclib.Server('http://192.168.1.10:1234') self.xmlrpc_client1_0_1 = xmlrpclib.Server('http://192.168.1.10:1234') self.xmlrpc_client1_0_0_1 = xmlrpclib.Server( 'http://192.168.1.10:1234') self.xmlrpc_client1_0_0_0_0 = xmlrpclib.Server( 'http://192.168.1.10:1234') self._tx_gain_range = Range(1, 89, 1, 10, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'tx gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0_2_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_2_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0_2_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_2_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_2_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_2_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_2_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_2_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_2_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_2_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_2_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_2_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_2_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget( self._qtgui_waterfall_sink_x_0_2_0_win, 3, 1, 1, 1) for r in range(3, 4): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 1, 1, 1, 1) for r in range(1, 2): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_2 = qtgui.time_sink_f( 1024, #size audio_rate, #samp_rate "CUBESAT AUDIO MOD", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_2.set_update_time(0.10) self.qtgui_time_sink_x_0_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_2.enable_tags(-1, True) self.qtgui_time_sink_x_0_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_2.enable_autoscale(False) self.qtgui_time_sink_x_0_2.enable_grid(False) self.qtgui_time_sink_x_0_2.enable_axis_labels(True) self.qtgui_time_sink_x_0_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_2_win = sip.wrapinstance( self.qtgui_time_sink_x_0_2.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_3.addWidget(self._qtgui_time_sink_x_0_2_win, 1, 1, 1, 1) for r in range(1, 2): self.tabs_grid_layout_3.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_3.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size audio_rate, #samp_rate "cubesat audio demod", #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_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_3.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 1, 1) for r in range(0, 1): self.tabs_grid_layout_3.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_3.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_1_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "CUBESAT MOD", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_1_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_1_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_1_1_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_1_0.enable_grid(False) self.qtgui_freq_sink_x_0_1_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_1_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_1_1_0.enable_control_panel(True) if not True: self.qtgui_freq_sink_x_0_1_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_1_1_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_1_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_1_1_0.pyqwidget(), Qt.QWidget) self.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_1_1_0_win, 2, 1, 1, 1) for r in range(2, 3): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "CUBESAT DEMOD", #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_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(True) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] 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.tabs_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 1, 1, 1) for r in range(0, 1): self.tabs_grid_layout_0.setRowStretch(r, 1) for c in range(1, 2): self.tabs_grid_layout_0.setColumnStretch(c, 1) self._gain_range = Range(1, 89, 1, 40, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "rx gain", "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._freq_chooser_options = ( 144.39e6, 137.62e6, 137.9125e6, 137.1e6, 88.5e6, ) self._freq_chooser_labels = ( 'APRS (144.39MHz)', 'NOAA-15 (137.62MHz)', 'NOAA-18 (137.9125MHz)', 'NOAA-19 (137.1MHz)', 'FM (88.5MHz)', ) self._freq_chooser_group_box = Qt.QGroupBox( 'APRS/NOAA Satellite Frequencies') self._freq_chooser_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._freq_chooser_button_group = variable_chooser_button_group() self._freq_chooser_group_box.setLayout(self._freq_chooser_box) for i, label in enumerate(self._freq_chooser_labels): radio_button = Qt.QRadioButton(label) self._freq_chooser_box.addWidget(radio_button) self._freq_chooser_button_group.addButton(radio_button, i) self._freq_chooser_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_chooser_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._freq_chooser_options.index(i))) self._freq_chooser_callback(self.freq_chooser) self._freq_chooser_button_group.buttonClicked[int].connect( lambda i: self.set_freq_chooser(self._freq_chooser_options[i])) self.top_grid_layout.addWidget(self._freq_chooser_group_box, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._freq_range = Range(100e6, 6e9, 100e3, freq_chooser, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, rf_rx_rate, True) self._audio_line_driver_range = Range(0.01, 1, 0.01, 0.8, 200) self._audio_line_driver_win = RangeWidget( self._audio_line_driver_range, self.set_audio_line_driver, 'audio line driver', "counter_slider", float) self.top_grid_layout.addWidget(self._audio_line_driver_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0_1_1_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_waterfall_sink_x_0_2_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.zeromq_pull_source_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.zeromq_pull_source_0_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.zeromq_pull_source_0_0_0_0, 0), (self.qtgui_time_sink_x_0_2, 0))
def __init__(self): gr.top_block.__init__(self, "Master") Qt.QWidget.__init__(self) self.setWindowTitle("Master") 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", "master") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.n_points = n_points = 5000 self.downsample = downsample = 50 self.transition = transition = 2e5 self.slope_samples = slope_samples = 100 self.samp_rate1 = samp_rate1 = 48000 self.samp_rate = samp_rate = 1e6 self.rx_gain = rx_gain = 50 self.rtl_samp_rate = rtl_samp_rate = 1e6 self.pi = pi = 3.1415926535 self.freq_correction_default = freq_correction_default = -0.16 self.freq = freq = 2.1e9 self.down_width = down_width = n_points / downsample self.cutoff = cutoff = 1e5 self.calibrate = calibrate = 1 self.c = c = 299792458 self.audio_gain = audio_gain = 0.5 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Aligned DOA') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'X-Corr') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Messages') self.top_layout.addWidget(self.tab) self._freq_range = Range(80e6, 2.2e9, 100e3, 2.1e9, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win, 0, 0, 1, 2) self._audio_gain_range = Range(0, 1, 0.1, 0.5, 100) self._audio_gain_win = RangeWidget(self._audio_gain_range, self.set_audio_gain, 'Audio Gain', "counter_slider", float) self.top_layout.addWidget(self._audio_gain_win) self.zeromq_pull_source_0_1 = zeromq.pull_source( gr.sizeof_float, 1, 'tcp://10.42.0.51:9997', 100, False, -1) self.zeromq_pull_source_0_0_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, 'tcp://10.42.0.51:9998', 100, False, -1) self.zeromq_pull_source_0_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, 'tcp://10.42.0.51:9992', 10000, False, -1) self.zeromq_pull_source_0 = zeromq.pull_source( gr.sizeof_gr_complex, 1, 'tcp://10.42.0.51:9991', 10000, False, -1) self.xmlrpc_client0 = xmlrpclib.Server('http://10.42.0.51:30000') self.xmlrpc_client = xmlrpclib.Server('http://10.42.0.51:30000') self._rx_gain_range = Range(0, 70, 1, 50, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RF Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 1, 0, 1, 2) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size 409, #samp_rate "Capon DOA Angle", #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(-3.2, 3.2) self.qtgui_time_sink_x_0.set_y_label('Angle', "radians") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 3, 0, 1, 3) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.01) self.qtgui_number_sink_0.set_title("Degree") 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 xrange(1): self.qtgui_number_sink_0.set_min(i, -180) self.qtgui_number_sink_0.set_max(i, 180) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(True) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc 1e6, #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_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0.enable_axis_labels(True) 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.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_edit_box_msg_0_1 = qtgui.edit_box_msg( qtgui.STRING, 'reset_buffer', 'Reset Alignment Buffer', False, False, 'recalc') self._qtgui_edit_box_msg_0_1_win = sip.wrapinstance( self.qtgui_edit_box_msg_0_1.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_edit_box_msg_0_1_win) self.qtgui_edit_box_msg_0_0 = qtgui.edit_box_msg( qtgui.FLOAT, '0', 'Reset Sample Drift Correction', True, False, 'reset_sum') self._qtgui_edit_box_msg_0_0_win = sip.wrapinstance( self.qtgui_edit_box_msg_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_edit_box_msg_0_0_win) self.doa_capon_ccf_0_0 = doa.capon_ccf(down_width) _calibrate_check_box = Qt.QCheckBox('Enable Calibration') self._calibrate_choices = {True: 1, False: 0} self._calibrate_choices_inv = dict( (v, k) for k, v in self._calibrate_choices.iteritems()) self._calibrate_callback = lambda i: Qt.QMetaObject.invokeMethod( _calibrate_check_box, "setChecked", Qt.Q_ARG("bool", self._calibrate_choices_inv[i])) self._calibrate_callback(self.calibrate) _calibrate_check_box.stateChanged.connect( lambda i: self.set_calibrate(self._calibrate_choices[bool(i)])) self.top_layout.addWidget(_calibrate_check_box) self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, down_width) self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, down_width) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vff( (180 / pi, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff( (audio_gain, )) self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, 50) self.blocks_keep_one_in_n_2 = blocks.keep_one_in_n( gr.sizeof_gr_complex * 1, 50) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, '/home/coding/Desktop/5', False) self.blocks_file_sink_1.set_unbuffered(False) self.audio_sink_0 = audio.sink(48000, '', True) ################################################## # Connections ################################################## self.connect((self.blocks_keep_one_in_n_2, 0), (self.blocks_stream_to_vector_0_1, 0)) self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_stream_to_vector_0_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_3, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.doa_capon_ccf_0_0, 0)) self.connect((self.blocks_stream_to_vector_0_1, 0), (self.doa_capon_ccf_0_0, 1)) self.connect((self.doa_capon_ccf_0_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.doa_capon_ccf_0_0, 0), (self.blocks_multiply_const_vxx_3, 0)) self.connect((self.doa_capon_ccf_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.blocks_keep_one_in_n_3, 0)) self.connect((self.zeromq_pull_source_0_0, 0), (self.blocks_keep_one_in_n_2, 0)) self.connect((self.zeromq_pull_source_0_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.zeromq_pull_source_0_1, 0), (self.blocks_multiply_const_vxx_0_0, 0))