def __init__(self):
        gr.top_block.__init__(self, "Receive_airprobe_bladerf")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_msg_source_0 = zeromq.sub_msg_source(
            "tcp://192.168.42.2:4729", 1)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, "packet_len")
        self.blocks_file_meta_sink_0 = blocks.file_meta_sink(
            gr.sizeof_gr_complex * 1,
            "/home/abhishek/tmp/Untitled Folder/data_bladeRF1/test", samp_rate,
            1, blocks.GR_FILE_FLOAT, True, 48000, "", True)
        self.blocks_file_meta_sink_0.set_unbuffered(False)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.zeromq_sub_msg_source_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.blocks_file_meta_sink_0, 0))
Exemplo n.º 2
0
    def setUp(self):
        addr = 'tcp://127.0.0.1'
        self.context = zmq.Context()
        self.zmq_sock = self.context.socket(zmq.PUB)
        port = self.zmq_sock.bind_to_random_port(addr)

        self.zeromq_sub_msg_source = zeromq.sub_msg_source(
            ('%s:%s' % (addr, port)), 100)
        self.message_debug = blocks.message_debug()
        self.tb = gr.top_block()
        self.tb.msg_connect(
            (self.zeromq_sub_msg_source, 'out'), (self.message_debug, 'store'))

        self.tb.start()
        time.sleep(0.1)
Exemplo n.º 3
0
    def __init__(self):
        gr.top_block.__init__(self, "File Meta Source")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_msg_source_0 = zeromq.sub_msg_source(
            "tcp://192.168.42.2:4729", 100000)
        self.SVM_prediction_printer_0 = SVM.prediction_printer(
            "No Person", "Person Walking", 50, 0.5)
        self.SVM_Test_0 = SVM.Test()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.SVM_Test_0, 'out'),
                         (self.SVM_prediction_printer_0, 'in'))
        self.msg_connect((self.zeromq_sub_msg_source_0, 'out'),
                         (self.SVM_Test_0, 'data'))
Exemplo n.º 4
0
    def __init__(self, fD=10, id_user=0):
        gr.top_block.__init__(self, "Polar Coding with Coded Caching")

        ##################################################
        # Parameters
        ##################################################
        self.fD = fD
        self.id_user = id_user

        ##################################################
        # Variables
        ##################################################
        self.snr = snr = 14 + 20 * numpy.log10(4)
        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.variance = variance = 1 / pow(10, snr / 10.0)
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        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.small_packet_len = small_packet_len = 52
        self.samp_rate = samp_rate = int(1e6)
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 0, 1)
        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, 0, 1)
        self.gain = gain = 25
        self.freq = freq = 2450e6
        self.coderate = coderate = [1, 2, 2, 3, 4]
        self.Users = Users = 4
        self.Nbfiles = Nbfiles = 20
        self.NbStrgUsers = NbStrgUsers = 1
        self.NbChuncks = NbChuncks = 200
        self.N = N = 2048

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     'tcp://localhost:5565',
                                                     100, False, -1)
        self.zeromq_sub_msg_source_0_0_0 = zeromq.sub_msg_source(
            'tcp://localhost:5575', 10)
        self.zeromq_sub_msg_source_0_0 = zeromq.sub_msg_source(
            'tcp://localhost:5555', 10)
        self.projectCACHE_ofdm_frame_equalizer1_vcvc_0 = projectCACHE.ofdm_frame_equalizer1_vcvc(
            fft_len, fft_len / 4, length_tag_key, True, occupied_carriers,
            pilot_carriers, pilot_symbols, 0, True)
        self.projectCACHE_PolarDec_b_0_0 = projectCACHE.PolarDec_b(
            N, Nbfiles, NbChuncks, id_user, Users, small_packet_len, 42,
            coderate[id_user], packet_length_tag_key)
        self.projectCACHE_PC_Error_Rate_0_0 = projectCACHE.PC_Error_Rate(
            id_user, 200)
        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_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(
            3, 1000, 0.0001)
        self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len / 4, False, 0.9)
        self.digital_ofdm_serializer_vcc_payload_0 = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, packet_length_tag_key,
            1, '', True)
        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_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,
            (),
            0,
        )
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            header_mod.base())
        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.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'),
                         (self.projectCACHE_PC_Error_Rate_0_0, 'SNR'))
        self.msg_connect((self.zeromq_sub_msg_source_0_0, 'out'),
                         (self.projectCACHE_PC_Error_Rate_0_0, 'BER_INFO'))
        self.msg_connect((self.zeromq_sub_msg_source_0_0_0, 'out'),
                         (self.projectCACHE_PC_Error_Rate_0_0, 'CH_USE'))
        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.digital_header_payload_demux_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_packet_headerparser_b_0, 0))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.fft_vxx_1, 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_serializer_vcc_header, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload, 0),
                     (self.projectCACHE_PolarDec_b_0_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload_0, 0),
                     (self.digital_probe_mpsk_snr_est_c_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.digital_header_payload_demux_0, 1))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_chanest_vcvc_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.digital_ofdm_serializer_vcc_payload_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0))
        self.connect((self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0),
                     (self.digital_ofdm_serializer_vcc_payload, 0))
        self.connect((self.zeromq_sub_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.digital_ofdm_sync_sc_cfb_0, 0))
Exemplo n.º 5
0
    def __init__(self, id_user=0):
        gr.top_block.__init__(self, "Polar Coding with Coded Caching")

        ##################################################
        # Parameters
        ##################################################
        self.id_user = id_user

        ##################################################
        # Variables
        ##################################################
        self.snr = snr = 50
        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.Kw = Kw = 70 * 8
        self.variance = variance = 1 / pow(10, snr / 10.0)
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        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.small_packet_len = small_packet_len = 52
        self.samp_rate = samp_rate = 32000
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 0, 1)
        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, 0, 1)
        self.coderate = coderate = [1, 2, 3, 3, 4]
        self.Users = Users = 4
        self.Nbfiles = Nbfiles = 20
        self.NbStrgUsers = NbStrgUsers = 1
        self.NbChuncks = NbChuncks = 200
        self.N = N = 2048
        self.Ks = Ks = 2 * Kw

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_msg_source_0_0_0 = zeromq.sub_msg_source(
            'tcp://localhost:5575', 10)
        self.zeromq_sub_msg_source_0_0 = zeromq.sub_msg_source(
            'tcp://localhost:5555', 10)
        self.zeromq_pub_msg_sink_0_0_0 = zeromq.pub_msg_sink(
            'tcp://*:5575', 10)
        self.zeromq_pub_msg_sink_0_0 = zeromq.pub_msg_sink('tcp://*:5555', 10)
        self.projectCACHE_polarEnc_b_0_0 = projectCACHE.polarEnc_b(
            N, Nbfiles, NbChuncks, NbStrgUsers, id_user, small_packet_len,
            packet_length_tag_key)
        self.projectCACHE_ofdm_frame_equalizer1_vcvc_0 = projectCACHE.ofdm_frame_equalizer1_vcvc(
            fft_len, fft_len / 4, length_tag_key, True, occupied_carriers,
            pilot_carriers, pilot_symbols, 0, True)
        self.projectCACHE_map_header_payload_bc_0 = projectCACHE.map_header_payload_bc(
            4, 2, packet_length_tag_key)
        self.projectCACHE_PolarDec_b_0_0 = projectCACHE.PolarDec_b(
            N, Nbfiles, NbChuncks, id_user, Users, small_packet_len, 42,
            coderate[id_user], packet_length_tag_key)
        self.projectCACHE_PC_Error_Rate_0_0 = projectCACHE.PC_Error_Rate(
            id_user, 200)
        self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (()), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (()), True, 1)
        self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(
            3, 1000, 0.0001)
        self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(
            header_formatter.formatter(), packet_length_tag_key)
        self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len / 4, False, 0.9)
        self.digital_ofdm_serializer_vcc_payload_0 = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, packet_length_tag_key,
            1, '', True)
        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_0 = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(), fft_len / 4, length_tag_key, True, 1)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + fft_len / 4, 0, packet_length_tag_key)
        self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc(
            (sync_word1), (sync_word2), 1, 0, 3, False)
        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_length_tag_key)
        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,
            (),
            0,
        )
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            header_mod.base())
        self.digital_chunks_to_symbols_xx_0_1 = digital.chunks_to_symbols_bc(
            (header_mod.points()), 1)
        self.channels_channel_model_0_0 = channels.channel_model(
            noise_voltage=numpy.sqrt(variance),
            frequency_offset=1.0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   samp_rate, True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, 'packet_len')
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, packet_length_tag_key, 0)
        (self.blocks_tagged_stream_mux_0).set_max_output_buffer(8192)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 False)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.05, ))
        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.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.zeromq_pub_msg_sink_0_0_0, 'in'))
        self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'),
                         (self.digital_header_payload_demux_0, 'header_data'))
        self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'),
                         (self.projectCACHE_PC_Error_Rate_0_0, 'SNR'))
        self.msg_connect((self.projectCACHE_polarEnc_b_0_0, 'BER_INFO'),
                         (self.zeromq_pub_msg_sink_0_0, 'in'))
        self.msg_connect((self.zeromq_sub_msg_source_0_0, 'out'),
                         (self.projectCACHE_PC_Error_Rate_0_0, 'BER_INFO'))
        self.msg_connect((self.zeromq_sub_msg_source_0_0_0, 'out'),
                         (self.projectCACHE_PC_Error_Rate_0_0, 'CH_USE'))
        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_const_vxx_1, 0),
                     (self.blocks_throttle_0_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_header_payload_demux_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.blocks_throttle_0_0, 0),
                     (self.channels_channel_model_0_0, 0))
        self.connect((self.channels_channel_model_0_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.channels_channel_model_0_0, 0),
                     (self.digital_ofdm_sync_sc_cfb_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_1, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_packet_headerparser_b_0, 0))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.fft_vxx_1, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.digital_ofdm_chanest_vcvc_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_tag_gate_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0),
                     (self.digital_ofdm_serializer_vcc_header, 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.projectCACHE_PolarDec_b_0_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload_0, 0),
                     (self.digital_probe_mpsk_snr_est_c_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.digital_header_payload_demux_0, 1))
        self.connect((self.digital_packet_headergenerator_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_1, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_chanest_vcvc_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.digital_ofdm_serializer_vcc_payload_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0))
        self.connect((self.projectCACHE_map_header_payload_bc_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0),
                     (self.digital_ofdm_serializer_vcc_payload, 0))
        self.connect((self.projectCACHE_polarEnc_b_0_0, 0),
                     (self.digital_packet_headergenerator_bb_0, 0))
        self.connect((self.projectCACHE_polarEnc_b_0_0, 0),
                     (self.projectCACHE_map_header_payload_bc_0, 0))
Exemplo n.º 6
0
    def __init__(self, gain=5, id_user=0):
        gr.top_block.__init__(self, "Polar Coding with Coded Caching")

        ##################################################
        # Parameters
        ##################################################
        self.gain = gain
        self.id_user = id_user

        ##################################################
        # 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.Kw = Kw = 70*8
        self.sync_word2 = sync_word2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0]
        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.small_packet_len = small_packet_len = 52
        self.samp_rate = samp_rate = int(1e6)
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1)
        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, 0, 1)
        self.freq = freq = 2450e6
        self.coderate = coderate = [3,3,3,3,4]
        self.Users = Users = 4
        self.Nbfiles = Nbfiles = 20
        self.NbStrgUsers = NbStrgUsers = 1
        self.NbChuncks = NbChuncks = 200
        self.N = N = 2048
        self.Ks = Ks = 2*Kw

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_msg_source_0_0_0 = zeromq.sub_msg_source('tcp://mnode16:5575', 10)
        self.zeromq_sub_msg_source_0_0 = zeromq.sub_msg_source('tcp://mnode16:5555', 100)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(('', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0_0.set_clock_source('external', 0)
        self.uhd_usrp_source_0_0.set_time_source('external', 0)
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0_0.set_gain(gain, 0)
        self.uhd_usrp_source_0_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_source_0_0.set_auto_dc_offset(True, 0)
        self.uhd_usrp_source_0_0.set_auto_iq_balance(True, 0)
        self.projectCACHE_ofdm_frame_equalizer1_vcvc_0 = projectCACHE.ofdm_frame_equalizer1_vcvc(fft_len, fft_len/4, length_tag_key, True, occupied_carriers, pilot_carriers, pilot_symbols, 0, True)
        self.projectCACHE_PolarDec_b_0_0 = projectCACHE.PolarDec_b(N, Nbfiles, NbChuncks, id_user, Users, small_packet_len, 42, coderate[id_user], packet_length_tag_key)
        self.projectCACHE_PC_Error_Rate_0 = projectCACHE.PC_Error_Rate(id_user, 200)
        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_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(3, 1000, 0.001)
        self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(header_formatter.base())
        self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(fft_len, fft_len/4, False, 0.9)
        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_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,
                  (),
                  0,
            )
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*3.14/100, 2, False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base())
        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.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.projectCACHE_PC_Error_Rate_0, 'SNR'))
        self.msg_connect((self.zeromq_sub_msg_source_0_0, 'out'), (self.projectCACHE_PC_Error_Rate_0, 'BER_INFO'))
        self.msg_connect((self.zeromq_sub_msg_source_0_0_0, 'out'), (self.projectCACHE_PC_Error_Rate_0, 'CH_USE'))
        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.digital_header_payload_demux_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0))
        self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 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_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.digital_probe_mpsk_snr_est_c_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.projectCACHE_PolarDec_b_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.digital_header_payload_demux_0, 1))
        self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0))
        self.connect((self.fft_vxx_1, 0), (self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0))
        self.connect((self.projectCACHE_ofdm_frame_equalizer1_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_payload, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_costas_loop_cc_0, 0))
Exemplo n.º 7
0
    def __init__(self, doc, ip="127.0.0.1"):
        gr.top_block.__init__(self, "RL Demod training")
        self.doc = doc
        self.plot_lst = []
        self.widget_lst = []

        ##################################################
        # Parameters
        ##################################################
        self.ip = ip

        ##################################################
        # Variables
        ##################################################
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.packet_length_tag_key = packet_length_tag_key = "packet_length"
        self.occupied_carriers = occupied_carriers = (
            list(range(-22, -21)) + list(range(-20, -7)) + list(range(-6, 0)) +
            list(range(1, 7)) + list(range(8, 21)) + list(range(22, 23)), )
        self.length_tag_key_0 = length_tag_key_0 = "frame_len"
        self.length_tag_key = length_tag_key = "packet_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.errors = errors = 0
        self.bits_per_symbol = bits_per_symbol = 4
        self.ber = ber = 0
        self.variable_qtgui_label_0_0_val = variable_qtgui_label_0_0 = ber
        self.variable_qtgui_label_0_val = variable_qtgui_label_0 = errors
        self.variable_0 = variable_0 = len(occupied_carriers[0])
        self.training_mod = training_mod = 1
        self.timestamp = timestamp = '1'
        self.t_state = t_state = 1
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        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.snr_stop = snr_stop = 29
        self.snr_step = snr_step = 0.5
        self.snr_start = snr_start = 0
        self.samp_rate = samp_rate = 0.3e6
        self.rx_lr = rx_lr = -2
        self.rolloff = rolloff = 0
        self.puncpat = puncpat = '11'
        self.payload_mod = payload_mod = digital.qam_constellation(
            constellation_points=2**bits_per_symbol)
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_static(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 1)
        self.packet_len = packet_len = 400
        self.mag = mag = 10
        self.ldpc_enc = ldpc_enc = fec.ldpc_encoder_make(
            gr.prefix() + "/share/gnuradio/fec/ldpc/" +
            "n_0100_k_0042_gap_02.alist")
        self.ldpc_dec = ldpc_dec = fec.ldpc_decoder.make(
            gr.prefix() + "/share/gnuradio/fec/ldpc/" +
            "n_0100_k_0042_gap_02.alist", 0.5, 50)
        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_0,
            bits_per_header_sym=header_mod.bits_per_symbol(),
            bits_per_payload_sym=8,
            scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols)
        self.hdr_format = hdr_format = digital.header_format_ofdm(
            occupied_carriers,
            1,
            length_tag_key,
        )
        self.gain_rx = gain_rx = 5
        self.freq = freq = 900e6
        self.bits_per_symbol_0 = bits_per_symbol_0 = len(occupied_carriers[0])

        ##################################################
        # Blocks
        ##################################################
        self.training_mod_textbox = bokehgui.textbox(
            self.widget_lst, str(1), 'Alternate training every' + ": ")
        self.training_mod_textbox.add_callback(
            lambda attr, old, new: self.set_training_mod(int(new)))
        self._t_state_options = [
            1,
            0,
        ]
        self._t_state_labels = [
            'On',
            'Off',
        ]

        self.t_state_radiobutton = bokehgui.radiobutton(self.widget_lst,
                                                        None,
                                                        self._t_state_labels,
                                                        inline=True)
        self.t_state_radiobutton.add_callback(
            lambda new: self.set_t_state(int(self._t_state_options[new])))
        self.rx_lr_slider = bokehgui.slider(self.widget_lst,
                                            'RX Learning rate (log)' + ":", -5,
                                            0, 0.1, 1, -2)
        self.rx_lr_slider.add_callback(
            lambda attr, old, new: self.set_rx_lr(new))
        self.mag_slider = bokehgui.slider(self.widget_lst, 'Eb/N0' + ":", 0,
                                          40, 0.1, 1, 10)
        self.mag_slider.add_callback(lambda attr, old, new: self.set_mag(new))
        self.learning_ber_bf_0 = learning.ber_bf(False, 100, -7.0, 1)
        self.gain_rx_slider = bokehgui.slider(self.widget_lst,
                                              'Amplitude Rx' + ":", 0, 90, 0.5,
                                              1, 5)
        self.gain_rx_slider.add_callback(
            lambda attr, old, new: self.set_gain_rx(new))
        self.blocks_probe_signal_x_0 = blocks.probe_signal_f()
        self.zeromq_sub_msg_source_0_0 = zeromq.sub_msg_source(
            "tcp://" + ip + ":50001", 1000)
        self.zeromq_pub_msg_sink_0_0_0 = zeromq.pub_msg_sink(
            'tcp://*:50002', 1000)
        self.variable_qtgui_label_0_0 = bokehgui.label(
            self.widget_lst, str(variable_qtgui_label_0_0), 'BER' + ": ")
        self.variable_qtgui_label_0 = bokehgui.label(
            self.widget_lst, str(variable_qtgui_label_0), 'Error count' + ": ")
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )

        self.uhd_usrp_source_0.set_samp_rate(samp_rate)

        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)

        self.uhd_usrp_source_0.set_center_freq(freq, 0)

        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)

        self.uhd_usrp_source_0.set_rx_agc(False, 0)
        self.uhd_usrp_source_0.set_gain(gain_rx, 0)
        self.timestamp_textbox = bokehgui.textbox(self.widget_lst, str('1'),
                                                  'Load timestamp' + ": ")
        self.timestamp_textbox.add_callback(
            lambda attr, old, new: self.set_timestamp(str(new)))
        self.learning_dl_demod_0 = learning.dl_demod(
            'packet_num', False, bits_per_symbol, packet_len, 20, training_mod,
            10**rx_lr, t_state,
            '/home/cyrille/Gnu-Radio/modules/gr-learning/examples/saved_models'
        )
        self.learning_align_0 = learning.align('packet_num', packet_len, 1, 48)
        self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (), True, 1)

        def _errors_probe():
            while True:

                val = self.learning_ber_bf_0.total_errors()
                try:
                    self.set_errors(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (0.5))

        _errors_thread = threading.Thread(target=_errors_probe)
        _errors_thread.daemon = True
        _errors_thread.start()

        self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len // 4, False, 0.9)
        self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key_0,
            packet_length_tag_key, 1, '', True)
        self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key_0, '', 0, '', True)
        self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc(
            payload_equalizer.base(), fft_len // 4, length_tag_key_0, True, 0)
        self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(), fft_len // 4, length_tag_key_0, 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_0, "", True,
            gr.sizeof_gr_complex, "rx_time", int(samp_rate), (), 0)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            header_mod.base())
        self.bokehgui_time_sink_x_0 = bokehgui.time_sink_f_proc(
            1024, samp_rate, "Decoded minus label", 1)

        self.bokehgui_time_sink_x_0_plot = bokehgui.time_sink_f(
            self.doc,
            self.plot_lst,
            self.bokehgui_time_sink_x_0,
            is_message=False)

        labels = ['', '', '', '', '', '', '', '', '', '']
        legend_list = []
        for i in range(1):
            if len(labels[i]) == 0:
                legend_list.append("Data {0}".format(i))
            else:
                legend_list.append(labels[i])
        self.bokehgui_time_sink_x_0_plot.initialize(log_x=False,
                                                    log_y=False,
                                                    update_time=500,
                                                    legend_list=legend_list)

        self.bokehgui_time_sink_x_0_plot.set_y_axis([-10, 10])
        self.bokehgui_time_sink_x_0_plot.set_y_label('Difference' + '(' + "" +
                                                     ')')
        self.bokehgui_time_sink_x_0_plot.set_x_label('Symbol' + '(' + "" + ')')

        self.bokehgui_time_sink_x_0_plot.enable_tags(-1, True)
        self.bokehgui_time_sink_x_0_plot.set_trigger_mode(
            bokehgui.TRIG_MODE_FREE, bokehgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.bokehgui_time_sink_x_0_plot.enable_grid(False)
        self.bokehgui_time_sink_x_0_plot.enable_axis_labels(True)
        self.bokehgui_time_sink_x_0_plot.disable_legend(not True)
        self.bokehgui_time_sink_x_0_plot.set_layout(*((2, 0, 1, 3)))

        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "blue", "blue", "blue"
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        styles = [
            "solid", "solid", "solid", "solid", "solid", "solid", "solid",
            "solid", "solid", "solid"
        ]
        markers = [None, None, None, None, None, None, None, None, None, None]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in range(1):
            self.bokehgui_time_sink_x_0_plot.format_line(
                i, colors[i], widths[i], styles[i], markers[i], alphas[i])
        self.bokehgui_time_const_x_0 = bokehgui.time_sink_c_proc(
            1024, samp_rate, "Received noisy constellation", 1)

        self.bokehgui_time_const_x_0_plot = bokehgui.const_sink_c(
            self.doc,
            self.plot_lst,
            self.bokehgui_time_const_x_0,
            is_message=False)
        labels = ['', '', '', '', '', '', '', '', '', '']
        legend_list = []
        for i in range(1):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    legend_list.append("Re{{Data {0}}}".format(i / 2))
                else:
                    legend_list.append("Im{{Data {0}}}".format(i / 2))
            else:
                legend_list.append(labels[i])

        self.bokehgui_time_const_x_0_plot.initialize(update_time=500,
                                                     legend_list=legend_list)

        self.bokehgui_time_const_x_0_plot.set_y_axis([-2, 2])
        self.bokehgui_time_const_x_0_plot.set_y_label('Q Channel' + '(' + "" +
                                                      ')')

        self.bokehgui_time_const_x_0_plot.set_x_label('I Channel' + '(' + "" +
                                                      ')')
        self.bokehgui_time_const_x_0_plot.enable_tags(-1, False)
        self.bokehgui_time_const_x_0_plot.set_trigger_mode(
            bokehgui.TRIG_MODE_FREE, bokehgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.bokehgui_time_const_x_0_plot.enable_grid(True)
        self.bokehgui_time_const_x_0_plot.enable_axis_labels(True)
        self.bokehgui_time_const_x_0_plot.disable_legend(not True)
        self.bokehgui_time_const_x_0_plot.set_layout(*((0, 1, 2, 2)))
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "blue", "blue", "blue"
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = ['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o']
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in range(1):
            self.bokehgui_time_const_x_0_plot.format_line(
                i, colors[i], widths[i], 'None', markers[i], alphas[i])
        self.bokehgui_frequency_sink_x_0 = bokehgui.freq_sink_c_proc(
            1024, firdes.WIN_BLACKMAN_hARRIS, freq, samp_rate, "Rx signal", 1)
        self.bokehgui_frequency_sink_x_0_plot = bokehgui.freq_sink_c(
            self.doc,
            self.plot_lst,
            self.bokehgui_frequency_sink_x_0,
            is_message=False)
        labels = ['', '', '', '', '', '', '', '', '', '']
        legend_list = []

        for i in range(1):
            if len(labels[i]) == 0:
                legend_list.append("Data {0}".format(i))
            else:
                legend_list.append(labels[i])

        self.bokehgui_frequency_sink_x_0_plot.initialize(
            update_time=100, legend_list=legend_list)

        self.bokehgui_frequency_sink_x_0_plot.set_y_axis([-140, 10])
        self.bokehgui_frequency_sink_x_0_plot.set_y_label('Relative Gain' +
                                                          '(' + 'dB' + ')')
        self.bokehgui_frequency_sink_x_0_plot.set_x_label('Frequency' + '(' +
                                                          "Hz" + ')')

        self.bokehgui_frequency_sink_x_0_plot.set_trigger_mode(
            bokehgui.TRIG_MODE_FREE, 0.0, 0, "")

        self.bokehgui_frequency_sink_x_0_plot.enable_grid(False)
        self.bokehgui_frequency_sink_x_0_plot.enable_axis_labels(True)
        self.bokehgui_frequency_sink_x_0_plot.disable_legend(not True)
        self.bokehgui_frequency_sink_x_0_plot.set_layout(*((3, 0, 1, 3)))
        self.bokehgui_frequency_sink_x_0_plot.enable_max_hold()
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        styles = [
            "solid", "solid", "solid", "solid", "solid", "solid", "solid",
            "solid", "solid", "solid"
        ]
        markers = [None, None, None, None, None, None, None, None, None, None]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            self.bokehgui_frequency_sink_x_0_plot.format_line(
                i, colors[i], widths[i], styles[i], markers[i], alphas[i])
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_repack_bits_bb_0_0_1_1 = blocks.repack_bits_bb(
            bits_per_symbol, 1, '', False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_0_1 = blocks.repack_bits_bb(
            bits_per_symbol, 1, '', False, gr.GR_LSB_FIRST)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float *
                                                   bits_per_symbol)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           fft_len + 0 * (fft_len // 4) + 10)
        self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)

        def _ber_probe():
            while True:

                val = self.blocks_probe_signal_x_0.level()
                try:
                    self.set_ber(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (0.5))

        _ber_thread = threading.Thread(target=_ber_probe)
        _ber_thread.daemon = True
        _ber_thread.start()

        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN,
            np.sqrt(10**(np.log10(1 / bits_per_symbol) - (mag / 10.0))) * 1,
            -1)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            -2.0 / fft_len)

        if self.widget_lst:
            input_t = bokehgui.bokeh_layout.widgetbox(self.widget_lst)
            widgetbox = bokehgui.bokeh_layout.WidgetLayout(input_t)
            widgetbox.set_layout(*((0, 0, 2, 1)))
            list_obj = [widgetbox] + self.plot_lst
        else:
            list_obj = self.plot_lst
        layout_t = bokehgui.bokeh_layout.create_layout(list_obj,
                                                       "stretch_both")
        self.doc.add_root(layout_t)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'),
                         (self.digital_header_payload_demux_0, 'header_data'))
        self.msg_connect((self.learning_dl_demod_0, 'losses'),
                         (self.zeromq_pub_msg_sink_0_0_0, 'in'))
        self.msg_connect((self.zeromq_sub_msg_source_0_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.connect((self.analog_frequency_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.bokehgui_time_const_x_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.learning_align_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.blocks_char_to_float_0_0_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_header_payload_demux_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.learning_align_0, 1))
        self.connect((self.blocks_repack_bits_bb_0_0_1, 0),
                     (self.learning_ber_bf_0, 1))
        self.connect((self.blocks_repack_bits_bb_0_0_1_1, 0),
                     (self.learning_ber_bf_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.bokehgui_time_sink_x_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_packet_headerparser_b_0, 0))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.fft_vxx_1, 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.blocks_add_xx_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.digital_header_payload_demux_0, 1))
        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.learning_align_0, 1), (self.learning_dl_demod_0, 1))
        self.connect((self.learning_align_0, 0), (self.learning_dl_demod_0, 0))
        self.connect((self.learning_ber_bf_0, 0),
                     (self.blocks_probe_signal_x_0, 0))
        self.connect((self.learning_dl_demod_0, 1),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.learning_dl_demod_0, 2),
                     (self.blocks_char_to_float_0_0_0, 0))
        self.connect((self.learning_dl_demod_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.learning_dl_demod_0, 2),
                     (self.blocks_repack_bits_bb_0_0_1, 0))
        self.connect((self.learning_dl_demod_0, 1),
                     (self.blocks_repack_bits_bb_0_0_1_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.bokehgui_frequency_sink_x_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_ofdm_sync_sc_cfb_0, 0))
Exemplo n.º 8
0
    def __init__(self, server_address="127.0.0.1", udp_port=8888):
        gr.top_block.__init__(self, "Remote Monitor")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Remote Monitor")
        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", "remote_monitor")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.server_address = server_address
        self.udp_port = udp_port

        ##################################################
        # Variables
        ##################################################
        self.tune_freq = tune_freq = 100e6
        self.samp_rate = samp_rate = 1800000
        self.rf_gain = rf_gain = 5
        self.reset_max = reset_max = False
        self.rate = rate = 1
        self.precision = precision = True
        self.max_mtu = max_mtu = 10000
        self.av = av = 0.8

        ##################################################
        # Blocks
        ##################################################
        self._tune_freq_range = Range(0, 2000e6, 500, 100e6, 200)
        self._tune_freq_win = RangeWidget(self._tune_freq_range,
                                          self.set_tune_freq,
                                          'Tuning Frequency', "counter_slider",
                                          float)
        self.top_grid_layout.addWidget(self._tune_freq_win, 1, 0, 1, 2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": "))
        self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate))
        self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit)
        self._samp_rate_line_edit.returnPressed.connect(
            lambda: self.set_samp_rate(
                int(str(self._samp_rate_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 0, 0, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        _precision_check_box = Qt.QCheckBox('32bit FFT (or 16b)')
        self._precision_choices = {True: True, False: False}
        self._precision_choices_inv = dict(
            (v, k) for k, v in self._precision_choices.iteritems())
        self._precision_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _precision_check_box, "setChecked",
            Qt.Q_ARG("bool", self._precision_choices_inv[i]))
        self._precision_callback(self.precision)
        _precision_check_box.stateChanged.connect(
            lambda i: self.set_precision(self._precision_choices[bool(i)]))
        self.top_grid_layout.addWidget(_precision_check_box, 0, 3, 1, 1)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.zeromq_sub_msg_source_0 = zeromq.sub_msg_source(
            'tcp://127.0.0.1:5005', 100)
        self.xmlrpc_client5 = xmlrpclib.Server('http://127.0.0.1:7658')
        self.xmlrpc_client4_0_1 = xmlrpclib.Server('http://127.0.0.1:7658')
        self.xmlrpc_client4 = xmlrpclib.Server('http://127.0.0.1:7658')
        self.xmlrpc_client3 = xmlrpclib.Server('http://127.0.0.1:7658')
        self.xmlrpc_client2 = xmlrpclib.Server('http://127.0.0.1:7658')
        self.xmlrpc_client0_0 = xmlrpclib.Server('http://127.0.0.1:7658')
        self._rf_gain_range = Range(0, 50, 1, 5, 200)
        self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain,
                                        "rf_gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._rf_gain_win, 2, 0, 1, 2)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        _reset_max_check_box = Qt.QCheckBox('Max Reset')
        self._reset_max_choices = {True: True, False: False}
        self._reset_max_choices_inv = dict(
            (v, k) for k, v in self._reset_max_choices.iteritems())
        self._reset_max_callback = lambda i: Qt.QMetaObject.invokeMethod(
            _reset_max_check_box, "setChecked",
            Qt.Q_ARG("bool", self._reset_max_choices_inv[i]))
        self._reset_max_callback(self.reset_max)
        _reset_max_check_box.stateChanged.connect(
            lambda i: self.set_reset_max(self._reset_max_choices[bool(i)]))
        self.top_grid_layout.addWidget(_reset_max_check_box, 1, 3, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._rate_range = Range(1, 50, 1, 1, 200)
        self._rate_win = RangeWidget(self._rate_range, self.set_rate, "rate",
                                     "counter_slider", int)
        self.top_grid_layout.addWidget(self._rate_win, 0, 1, 1, 2)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.ofdm_tools_remote_client_qt_0_0 = ofdm_tools.remote_client_qt(
            tune_freq=tune_freq,
            sample_rate=samp_rate,
            show_axes='str(axes)',
            precision=precision,
            hold_max=False,
            label='Complex PSD Plot')
        self._ofdm_tools_remote_client_qt_0_0_win = self.ofdm_tools_remote_client_qt_0_0
        self.top_grid_layout.addWidget(
            self._ofdm_tools_remote_client_qt_0_0_win, 3, 0, 1, 4)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)

        self._av_range = Range(0, 1, 0.001, 0.8, 200)
        self._av_win = RangeWidget(self._av_range, self.set_av, "av",
                                   "counter_slider", float)
        self.top_grid_layout.addWidget(self._av_win, 1, 2, 1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.zeromq_sub_msg_source_0, 'out'),
                         (self.ofdm_tools_remote_client_qt_0_0, 'pdus'))
Exemplo n.º 9
0
    def __init__(
            self,
            configFile="~/.config/gr-amateur/AX25_Modem-HackRF-RTLSDR.ini",
            logLevel="debug"):
        gr.top_block.__init__(self, "AX.25 - AFSK1200 Modem GUI")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("AX.25 - AFSK1200 Modem GUI")
        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", "AX25_Modem_GUI")

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

        ##################################################
        # Parameters
        ##################################################
        self.configFile = configFile
        self.logLevel = logLevel

        ##################################################
        # Variables
        ##################################################
        self._rx_fs_config = ConfigParser.ConfigParser()
        self._rx_fs_config.read(configFile)
        try:
            rx_fs = self._rx_fs_config.getfloat('Receive', 'fs')
        except:
            rx_fs = 1.92e6
        self.rx_fs = rx_fs
        self.logLvl = logLvl = {
            "info": logging.INFO,
            "debug": logging.DEBUG,
            "warning": logging.WARNING,
            "warn": logging.WARN,
            "error": logging.ERROR
        }.get(logLevel.lower(), logging.INFO)
        self._afsk_bitRate_config = ConfigParser.ConfigParser()
        self._afsk_bitRate_config.read(configFile)
        try:
            afsk_bitRate = self._afsk_bitRate_config.getfloat(
                'AFSK', 'bitRate')
        except:
            afsk_bitRate = 1200.0
        self.afsk_bitRate = afsk_bitRate
        self.variable_qtgui_label_0_0 = variable_qtgui_label_0_0 = ""
        self.variable_qtgui_label_0 = variable_qtgui_label_0 = ""
        self._rx_freq_config = ConfigParser.ConfigParser()
        self._rx_freq_config.read(configFile)
        try:
            rx_freq = self._rx_freq_config.getfloat('Receive', 'freq')
        except:
            rx_freq = 144.39e6
        self.rx_freq = rx_freq
        self._rx_deviceArgs_config = ConfigParser.ConfigParser()
        self._rx_deviceArgs_config.read(configFile)
        try:
            rx_deviceArgs = self._rx_deviceArgs_config.get(
                'Receive', 'deviceArgs')
        except:
            rx_deviceArgs = ""
        self.rx_deviceArgs = rx_deviceArgs
        self.rootLogger = rootLogger = amateur.setupLogging(level=logLvl)
        self._debug_txCtrl_zmqAddr_config = ConfigParser.ConfigParser()
        self._debug_txCtrl_zmqAddr_config.read(configFile)
        try:
            debug_txCtrl_zmqAddr = self._debug_txCtrl_zmqAddr_config.get(
                'Debug', 'txCtrl_zmqAddr')
        except:
            debug_txCtrl_zmqAddr = "tcp://127.0.0.1:18737"
        self.debug_txCtrl_zmqAddr = debug_txCtrl_zmqAddr
        self._debug_syms_zmqAddr_config = ConfigParser.ConfigParser()
        self._debug_syms_zmqAddr_config.read(configFile)
        try:
            debug_syms_zmqAddr = self._debug_syms_zmqAddr_config.get(
                'Debug', 'syms_zmqAddr')
        except:
            debug_syms_zmqAddr = "tcp://127.0.0.1:18732"
        self.debug_syms_zmqAddr = debug_syms_zmqAddr
        self._debug_stats_zmqAddr_config = ConfigParser.ConfigParser()
        self._debug_stats_zmqAddr_config.read(configFile)
        try:
            debug_stats_zmqAddr = self._debug_stats_zmqAddr_config.get(
                'Debug', 'stats_zmqAddr')
        except:
            debug_stats_zmqAddr = "tcp://127.0.0.1:18735"
        self.debug_stats_zmqAddr = debug_stats_zmqAddr
        self._debug_snr_zmqAddr_config = ConfigParser.ConfigParser()
        self._debug_snr_zmqAddr_config.read(configFile)
        try:
            debug_snr_zmqAddr = self._debug_snr_zmqAddr_config.get(
                'Debug', 'snr_zmqAddr')
        except:
            debug_snr_zmqAddr = "tcp://127.0.0.1:18731"
        self.debug_snr_zmqAddr = debug_snr_zmqAddr
        self._debug_sent_zmqAddr_config = ConfigParser.ConfigParser()
        self._debug_sent_zmqAddr_config.read(configFile)
        try:
            debug_sent_zmqAddr = self._debug_sent_zmqAddr_config.get(
                'Debug', 'sent_zmqAddr')
        except:
            debug_sent_zmqAddr = "tcp://127.0.0.1:18734"
        self.debug_sent_zmqAddr = debug_sent_zmqAddr
        self._debug_rxCtrl_zmqAddr_config = ConfigParser.ConfigParser()
        self._debug_rxCtrl_zmqAddr_config.read(configFile)
        try:
            debug_rxCtrl_zmqAddr = self._debug_rxCtrl_zmqAddr_config.get(
                'Debug', 'rxCtrl_zmqAddr')
        except:
            debug_rxCtrl_zmqAddr = "tcp://127.0.0.1:18738"
        self.debug_rxCtrl_zmqAddr = debug_rxCtrl_zmqAddr
        self._debug_recv_zmqAddr_config = ConfigParser.ConfigParser()
        self._debug_recv_zmqAddr_config.read(configFile)
        try:
            debug_recv_zmqAddr = self._debug_recv_zmqAddr_config.get(
                'Debug', 'recv_zmqAddr')
        except:
            debug_recv_zmqAddr = "tcp://127.0.0.1:18733"
        self.debug_recv_zmqAddr = debug_recv_zmqAddr
        self._debug_cs_zmqAddr_config = ConfigParser.ConfigParser()
        self._debug_cs_zmqAddr_config.read(configFile)
        try:
            debug_cs_zmqAddr = self._debug_cs_zmqAddr_config.get(
                'Debug', 'cs_zmqAddr')
        except:
            debug_cs_zmqAddr = "tcp://127.0.0.1:18736"
        self.debug_cs_zmqAddr = debug_cs_zmqAddr
        self._debug_bb_zmqAddr_config = ConfigParser.ConfigParser()
        self._debug_bb_zmqAddr_config.read(configFile)
        try:
            debug_bb_zmqAddr = self._debug_bb_zmqAddr_config.get(
                'Debug', 'bb_zmqAddr')
        except:
            debug_bb_zmqAddr = "tcp://127.0.0.1:18730"
        self.debug_bb_zmqAddr = debug_bb_zmqAddr
        self.Fs_bb = Fs_bb = min([rx_fs / afsk_bitRate, 20]) * afsk_bitRate

        ##################################################
        # Blocks
        ##################################################
        self.statTab = Qt.QTabWidget()
        self.statTab_widget_0 = Qt.QWidget()
        self.statTab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.statTab_widget_0)
        self.statTab_grid_layout_0 = Qt.QGridLayout()
        self.statTab_layout_0.addLayout(self.statTab_grid_layout_0)
        self.statTab.addTab(self.statTab_widget_0, 'Statistics')
        self.top_grid_layout.addWidget(self.statTab, 0, 6, 3, 2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 3)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(6, 8)]
        self.plotTab = Qt.QTabWidget()
        self.plotTab_widget_0 = Qt.QWidget()
        self.plotTab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.plotTab_widget_0)
        self.plotTab_grid_layout_0 = Qt.QGridLayout()
        self.plotTab_layout_0.addLayout(self.plotTab_grid_layout_0)
        self.plotTab.addTab(self.plotTab_widget_0, 'Spectrum')
        self.plotTab_widget_1 = Qt.QWidget()
        self.plotTab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.plotTab_widget_1)
        self.plotTab_grid_layout_1 = Qt.QGridLayout()
        self.plotTab_layout_1.addLayout(self.plotTab_grid_layout_1)
        self.plotTab.addTab(self.plotTab_widget_1, 'Time')
        self.top_grid_layout.addWidget(self.plotTab, 0, 0, 8, 6)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 8)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 6)]
        self.msgTab = Qt.QTabWidget()
        self.msgTab_widget_0 = Qt.QWidget()
        self.msgTab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                             self.msgTab_widget_0)
        self.msgTab_grid_layout_0 = Qt.QGridLayout()
        self.msgTab_layout_0.addLayout(self.msgTab_grid_layout_0)
        self.msgTab.addTab(self.msgTab_widget_0, 'Messages')
        self.msgTab_widget_1 = Qt.QWidget()
        self.msgTab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                             self.msgTab_widget_1)
        self.msgTab_grid_layout_1 = Qt.QGridLayout()
        self.msgTab_layout_1.addLayout(self.msgTab_grid_layout_1)
        self.msgTab.addTab(self.msgTab_widget_1, 'Console')
        self.msgTab_widget_2 = Qt.QWidget()
        self.msgTab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                             self.msgTab_widget_2)
        self.msgTab_grid_layout_2 = Qt.QGridLayout()
        self.msgTab_layout_2.addLayout(self.msgTab_grid_layout_2)
        self.msgTab.addTab(self.msgTab_widget_2, 'Beacon')
        self.top_grid_layout.addWidget(self.msgTab, 8, 0, 8, 8)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(8, 16)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 8)]
        self.ctrlTab = Qt.QTabWidget()
        self.ctrlTab_widget_0 = Qt.QWidget()
        self.ctrlTab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom,
                                              self.ctrlTab_widget_0)
        self.ctrlTab_grid_layout_0 = Qt.QGridLayout()
        self.ctrlTab_layout_0.addLayout(self.ctrlTab_grid_layout_0)
        self.ctrlTab.addTab(self.ctrlTab_widget_0, 'Control')
        self.top_grid_layout.addWidget(self.ctrlTab, 3, 6, 5, 2)
        [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 8)]
        [self.top_grid_layout.setColumnStretch(c, 1) for c in range(6, 8)]
        self.zeromq_sub_source_0_0_0_0 = zeromq.sub_source(
            gr.sizeof_char, 1, debug_cs_zmqAddr, 5, False, -1)
        self.zeromq_sub_source_0_0_0 = zeromq.sub_source(
            gr.sizeof_float, 1, debug_syms_zmqAddr, 10, False, -1)
        self.zeromq_sub_source_0_0 = zeromq.sub_source(gr.sizeof_float, 1,
                                                       debug_snr_zmqAddr, 10,
                                                       False, -1)
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     debug_bb_zmqAddr, 10,
                                                     False, -1)
        self.zeromq_sub_msg_source_0_0_0 = zeromq.sub_msg_source(
            debug_stats_zmqAddr, 10)
        self.zeromq_sub_msg_source_0_0 = zeromq.sub_msg_source(
            debug_sent_zmqAddr, 10)
        self.zeromq_sub_msg_source_0 = zeromq.sub_msg_source(
            debug_recv_zmqAddr, 10)
        self.zeromq_pub_msg_sink_0_0_0_0 = zeromq.pub_msg_sink(
            debug_rxCtrl_zmqAddr, 10)
        self.zeromq_pub_msg_sink_0_0_0 = zeromq.pub_msg_sink(
            debug_txCtrl_zmqAddr, 10)
        self._variable_qtgui_label_0_0_tool_bar = Qt.QToolBar(self)

        if None:
            self._variable_qtgui_label_0_0_formatter = None
        else:
            self._variable_qtgui_label_0_0_formatter = lambda x: str(x)

        self._variable_qtgui_label_0_0_tool_bar.addWidget(
            Qt.QLabel("Transmit" + ": "))
        self._variable_qtgui_label_0_0_label = Qt.QLabel(
            str(
                self._variable_qtgui_label_0_0_formatter(
                    self.variable_qtgui_label_0_0)))
        self._variable_qtgui_label_0_0_tool_bar.addWidget(
            self._variable_qtgui_label_0_0_label)
        self.msgTab_grid_layout_0.addWidget(
            self._variable_qtgui_label_0_0_tool_bar, 0, 0, 1, 4)
        [self.msgTab_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)]
        [self.msgTab_grid_layout_0.setColumnStretch(c, 1) for c in range(0, 4)]
        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: str(x)

        self._variable_qtgui_label_0_tool_bar.addWidget(
            Qt.QLabel("Receive" + ": "))
        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.msgTab_grid_layout_0.addWidget(
            self._variable_qtgui_label_0_tool_bar, 0, 4, 1, 4)
        [self.msgTab_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)]
        [self.msgTab_grid_layout_0.setColumnStretch(c, 1) for c in range(4, 8)]
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq,  #fc
            Fs_bb,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.025)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not False:
            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(-100, 0)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.plotTab_grid_layout_0.addWidget(
            self._qtgui_waterfall_sink_x_0_win, 3, 0, 5, 8)
        [self.plotTab_grid_layout_0.setRowStretch(r, 1) for r in range(3, 8)]
        [
            self.plotTab_grid_layout_0.setColumnStretch(c, 1)
            for c in range(0, 8)
        ]
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            int(afsk_bitRate * 2),  #size
            afsk_bitRate,  #samp_rate
            "Symbols",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1.25, 1.25)

        self.qtgui_time_sink_x_0_0.set_y_label("", "")

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        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)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-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_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.plotTab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win,
                                             4, 0, 4, 8)
        [self.plotTab_grid_layout_1.setRowStretch(r, 1) for r in range(4, 8)]
        [
            self.plotTab_grid_layout_1.setColumnStretch(c, 1)
            for c in range(0, 8)
        ]
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            int(Fs_bb * 2),  #size
            Fs_bb,  #samp_rate
            "SNR",  #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(-10, 30)

        self.qtgui_time_sink_x_0.set_y_label("", "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.plotTab_grid_layout_1.addWidget(self._qtgui_time_sink_x_0_win, 0,
                                             0, 4, 8)
        [self.plotTab_grid_layout_1.setRowStretch(r, 1) for r in range(0, 4)]
        [
            self.plotTab_grid_layout_1.setColumnStretch(c, 1)
            for c in range(0, 8)
        ]
        self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                       qtgui.NUM_GRAPH_HORIZ,
                                                       2)
        self.qtgui_number_sink_0_0.set_update_time(0.10)
        self.qtgui_number_sink_0_0.set_title("")

        labels = [
            "{:8s}".format("SNR"), "{:8s}".format("CS"), '', '', '', '', '',
            '', '', ''
        ]
        units = ["dB", '', '', '', '', '', '', '', '', '']
        colors = [("blue", "red"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(2):
            self.qtgui_number_sink_0_0.set_min(i, -5)
            self.qtgui_number_sink_0_0.set_max(i, 20)
            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.statTab_grid_layout_0.addWidget(self._qtgui_number_sink_0_0_win,
                                             0, 0, 1, 4)
        [self.statTab_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.statTab_grid_layout_0.setColumnStretch(c, 1)
            for c in range(0, 4)
        ]
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            4096,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            rx_freq,  #fc
            Fs_bb,  #bw
            "Spectrum",  #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, 0)
        self.qtgui_freq_sink_x_0.set_y_label("", "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 = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "green", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in 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.plotTab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,
                                             0, 3, 8)
        [self.plotTab_grid_layout_0.setRowStretch(r, 1) for r in range(0, 3)]
        [
            self.plotTab_grid_layout_0.setColumnStretch(c, 1)
            for c in range(0, 8)
        ]
        self.qtgui_edit_box_msg_0_1 = qtgui.edit_box_msg(
            qtgui.FLOAT, '', "TX - Gain", True, True, "gain")
        self._qtgui_edit_box_msg_0_1_win = sip.wrapinstance(
            self.qtgui_edit_box_msg_0_1.pyqwidget(), Qt.QWidget)
        self.ctrlTab_grid_layout_0.addWidget(self._qtgui_edit_box_msg_0_1_win,
                                             2, 0, 1, 1)
        [self.ctrlTab_grid_layout_0.setRowStretch(r, 1) for r in range(2, 3)]
        [
            self.ctrlTab_grid_layout_0.setColumnStretch(c, 1)
            for c in range(0, 1)
        ]
        self.qtgui_edit_box_msg_0_0_0 = qtgui.edit_box_msg(
            qtgui.FLOAT, '', "RX - Gain", True, True, "gain")
        self._qtgui_edit_box_msg_0_0_0_win = sip.wrapinstance(
            self.qtgui_edit_box_msg_0_0_0.pyqwidget(), Qt.QWidget)
        self.ctrlTab_grid_layout_0.addWidget(
            self._qtgui_edit_box_msg_0_0_0_win, 3, 0, 1, 1)
        [self.ctrlTab_grid_layout_0.setRowStretch(r, 1) for r in range(3, 4)]
        [
            self.ctrlTab_grid_layout_0.setColumnStretch(c, 1)
            for c in range(0, 1)
        ]
        self.qtgui_edit_box_msg_0_0 = qtgui.edit_box_msg(
            qtgui.FLOAT, '', "RX - Frequency", True, True, "freq")
        self._qtgui_edit_box_msg_0_0_win = sip.wrapinstance(
            self.qtgui_edit_box_msg_0_0.pyqwidget(), Qt.QWidget)
        self.ctrlTab_grid_layout_0.addWidget(self._qtgui_edit_box_msg_0_0_win,
                                             1, 0, 1, 1)
        [self.ctrlTab_grid_layout_0.setRowStretch(r, 1) for r in range(1, 2)]
        [
            self.ctrlTab_grid_layout_0.setColumnStretch(c, 1)
            for c in range(0, 1)
        ]
        self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.FLOAT, '',
                                                       "TX - Frequency", True,
                                                       True, "freq")
        self._qtgui_edit_box_msg_0_win = sip.wrapinstance(
            self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget)
        self.ctrlTab_grid_layout_0.addWidget(self._qtgui_edit_box_msg_0_win, 0,
                                             0, 1, 1)
        [self.ctrlTab_grid_layout_0.setRowStretch(r, 1) for r in range(0, 1)]
        [
            self.ctrlTab_grid_layout_0.setColumnStretch(c, 1)
            for c in range(0, 1)
        ]
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.amateur_AX25_Packet_Decoder_0 = amateur.AX25_Packet_Decoder()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'),
                         (self.zeromq_pub_msg_sink_0_0_0, 'in'))
        self.msg_connect((self.qtgui_edit_box_msg_0_0, 'msg'),
                         (self.qtgui_freq_sink_x_0, 'freq'))
        self.msg_connect((self.qtgui_edit_box_msg_0_0, 'msg'),
                         (self.qtgui_waterfall_sink_x_0, 'freq'))
        self.msg_connect((self.qtgui_edit_box_msg_0_0, 'msg'),
                         (self.zeromq_pub_msg_sink_0_0_0_0, 'in'))
        self.msg_connect((self.qtgui_edit_box_msg_0_0_0, 'msg'),
                         (self.zeromq_pub_msg_sink_0_0_0_0, 'in'))
        self.msg_connect((self.qtgui_edit_box_msg_0_1, 'msg'),
                         (self.zeromq_pub_msg_sink_0_0_0, 'in'))
        self.msg_connect((self.zeromq_sub_msg_source_0, 'out'),
                         (self.amateur_AX25_Packet_Decoder_0, 'in'))
        self.connect((self.blocks_uchar_to_float_0, 0),
                     (self.qtgui_number_sink_0_0, 1))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.zeromq_sub_source_0_0, 0),
                     (self.qtgui_number_sink_0_0, 0))
        self.connect((self.zeromq_sub_source_0_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.zeromq_sub_source_0_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.zeromq_sub_source_0_0_0_0, 0),
                     (self.blocks_uchar_to_float_0, 0))
Exemplo n.º 10
0
    def __init__(self, doc, ip="127.0.0.1"):
        gr.top_block.__init__(self, "RL Mod training")
        self.doc = doc
        self.plot_lst = []
        self.widget_lst = []

        ##################################################
        # Parameters
        ##################################################
        self.ip = ip

        ##################################################
        # Variables
        ##################################################
        self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),)
        self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),)
        self.packet_length_tag_key = packet_length_tag_key = "packet_length"
        self.occupied_carriers = occupied_carriers = (list(range(-22, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 23)),)
        self.length_tag_key_0 = length_tag_key_0 = "frame_len"
        self.length_tag_key = length_tag_key = "packet_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.bits_per_symbol = bits_per_symbol = 4
        self.variable_0 = variable_0 = len(occupied_carriers[0])
        self.tx_lr = tx_lr = -3
        self.tx_explo = tx_explo = 0.15
        self.training_mod = training_mod = 1
        self.timestamp = timestamp = '1'
        self.t_state = t_state = 1
        self.sync_word2 = sync_word2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0]
        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.samp_rate = samp_rate = 0.3e6
        self.rolloff = rolloff = 0
        self.puncpat = puncpat = '11'
        self.payload_mod = payload_mod = digital.qam_constellation(constellation_points=2**bits_per_symbol)
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_static(fft_len,  occupied_carriers, pilot_carriers, pilot_symbols, 1)
        self.packet_len = packet_len = 400
        self.ldpc_enc = ldpc_enc = fec.ldpc_encoder_make(gr.prefix() + "/share/gnuradio/fec/ldpc/" + "n_0100_k_0042_gap_02.alist")
        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_0, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=8, scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols)
        self.hdr_format = hdr_format = digital.header_format_ofdm(occupied_carriers, 1, length_tag_key,)
        self.gain = gain = 10
        self.freq = freq = 900e6
        self.bits_per_symbol_0 = bits_per_symbol_0 = len(occupied_carriers[0])

        ##################################################
        # Blocks
        ##################################################
        self.tx_lr_slider = bokehgui.slider(self.widget_lst, 'TX Learning rate (log)' +":", -5, 0, 0.1, 1, -3)
        self.tx_lr_slider.add_callback(lambda attr, old, new: self.set_tx_lr(new))
        self.tx_explo_slider = bokehgui.slider(self.widget_lst, 'TX Exploration noise' +":", 0.001, 0.5, 0.001, 1, 0.15)
        self.tx_explo_slider.add_callback(lambda attr, old, new: self.set_tx_explo(new))
        self.training_mod_textbox = bokehgui.textbox(self.widget_lst, str(1), 'Alternate training every' +": ")
        self.training_mod_textbox.add_callback(
          lambda attr, old, new: self.set_training_mod(int(new)))
        self._t_state_options = [    1,     0,   ]
        self._t_state_labels = [      'On',      'Off',  ]

        self.t_state_radiobutton = bokehgui.radiobutton(self.widget_lst, None, self._t_state_labels, inline = True)
        self.t_state_radiobutton.add_callback(
                  lambda new: self.set_t_state(int(self._t_state_options[new])))
        self.gain_slider = bokehgui.slider(self.widget_lst, 'Amplitude' +":", 0, 90, 0.5, 1, 10)
        self.gain_slider.add_callback(lambda attr, old, new: self.set_gain(new))
        self.zeromq_sub_msg_source_0_1 = zeromq.sub_msg_source("tcp://"+ip+":50002", 100)
        self.zeromq_pub_msg_sink_0_0 = zeromq.pub_msg_sink('tcp://*:50001', 100)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0,1)),
            ),
            length_tag_key,
        )


        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)

        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)

        self.uhd_usrp_sink_0.set_center_freq(freq, 0)

        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)

        self.uhd_usrp_sink_0.set_gain(gain, 0)
        self.timestamp_textbox = bokehgui.textbox(self.widget_lst, str('1'), 'Load timestamp' +": ")
        self.timestamp_textbox.add_callback(
          lambda attr, old, new: self.set_timestamp(str(new)))
        self.learning_tag_numerotation_0 = learning.tag_numerotation('packet_num', packet_len, 4096, "bb")
        self.learning_rl_mod_0 = learning.rl_mod('packet_num', bits_per_symbol, packet_len, 1, training_mod, 10**tx_lr , tx_explo, t_state , '/home/cyrille/Gnu-Radio/modules/gr-learning/examples/saved_models')
        self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (), True, 1)
        self.fec_extended_encoder_1_0_0 = fec.extended_encoder(encoder_obj_list=ldpc_enc, threading= None, puncpat=puncpat)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, length_tag_key)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len,
            fft_len + fft_len//4,
            rolloff,
            length_tag_key)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key, True)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(header_mod.points(), 1)
        self.bokehgui_time_const_x_0 = bokehgui.time_sink_c_proc(1024, samp_rate, "Transmitted noiseless constellation",  1)

        self.bokehgui_time_const_x_0_plot = bokehgui.const_sink_c(self.doc, self.plot_lst, self.bokehgui_time_const_x_0, is_message = False)
        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        legend_list = []
        for i in range(  1 ):
          if len(labels[i]) == 0:
              if(i % 2 == 0):
                  legend_list.append("Re{{Data {0}}}".format(i/2))
              else:
                  legend_list.append("Im{{Data {0}}}".format(i/2))
          else:
              legend_list.append(labels[i])

        self.bokehgui_time_const_x_0_plot.initialize(update_time = 500,
                                    legend_list = legend_list)

        self.bokehgui_time_const_x_0_plot.set_y_axis([-2, 2])
        self.bokehgui_time_const_x_0_plot.set_y_label('Q Channel' + '(' +""+')')

        self.bokehgui_time_const_x_0_plot.set_x_label('I Channel' + '(' +""+')')
        self.bokehgui_time_const_x_0_plot.enable_tags(-1, False)
        self.bokehgui_time_const_x_0_plot.set_trigger_mode(bokehgui.TRIG_MODE_FREE, bokehgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.bokehgui_time_const_x_0_plot.enable_grid(False)
        self.bokehgui_time_const_x_0_plot.enable_axis_labels(True)
        self.bokehgui_time_const_x_0_plot.disable_legend(not True)
        self.bokehgui_time_const_x_0_plot.set_layout(*((0,1,2,2)))
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "blue", "blue", "blue"]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = ['o', 'o', 'o', 'o', 'o',
                   'o', 'o', 'o', 'o', 'o']
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in range(    1  ):
          self.bokehgui_time_const_x_0_plot.format_line(i, colors[i], widths[i], 'None', markers[i], alphas[i])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate/6,True)
        self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_key, 0)
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, length_tag_key)
        self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(8, 1, length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(1, bits_per_symbol, '', False, gr.GR_LSB_FIRST)
        self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc(0.01, 1)
        self.analog_random_source_x_0_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 2, 1000))), True)

        if self.widget_lst:
            input_t = bokehgui.bokeh_layout.widgetbox(self.widget_lst)
            widgetbox = bokehgui.bokeh_layout.WidgetLayout(input_t)
            widgetbox.set_layout(*((0, 0, 2, 1)))
            list_obj = [widgetbox] + self.plot_lst
        else:
            list_obj = self.plot_lst
        layout_t = bokehgui.bokeh_layout.create_layout(list_obj, "fixed")
        self.doc.add_root(layout_t)


        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self.zeromq_pub_msg_sink_0_0, 'in'))
        self.msg_connect((self.zeromq_sub_msg_source_0_1, 'out'), (self.learning_rl_mod_0, 'losses'))
        self.connect((self.analog_random_source_x_0_0, 0), (self.fec_extended_encoder_1_0_0, 0))
        self.connect((self.blocks_multiply_const_xx_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.learning_tag_numerotation_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_xx_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0_0, 0))
        self.connect((self.fec_extended_encoder_1_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.learning_rl_mod_0, 0), (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.learning_rl_mod_0, 1), (self.bokehgui_time_const_x_0, 0))
        self.connect((self.learning_tag_numerotation_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.learning_tag_numerotation_0, 0), (self.learning_rl_mod_0, 0))