矢量源受探头信号控制

时间:2018-12-11 11:38:54

标签: python thread-sleep gnuradio gnuradio-companion probe

我正在从事GRC项目,目前坚持创建自定义矢量源块。我希望此向量源在每次从探针接收到“ 1”时重置标签生成。向量源生成的序列是一个128位的伪随机码。附件中的image1显示了生成“ Vector_Genator_C.py”的Hier自定义块。我正在考虑修改Vector_Genator_C.py以将探测信号包含在if语句中,并使用.stop,.wait和.stop播放,但老实说我不知道​​该怎么做。探头的输入显示在image2中,生成的序列显示在image3中,所需的结果显示在image4中。

Vector_Genator_C.py文件为:

# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: Vector_Genator_C
# Author: zaki
# Description: zzz
# Generated: Tue Dec 11 10:49:22 2018
##################################################


from gnuradio import blocks
from gnuradio import gr
from gnuradio.filter import firdes
import threading
import time


class Vector_Genator_C(gr.hier_block2):

    def __init__(self, parameter_0=0):
        gr.hier_block2.__init__(
            self, "Vector_Genator_C",
            gr.io_signature(1, 1, gr.sizeof_char*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.parameter_0 = parameter_0

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 75e3
        self.probe_control = probe_control = 0

        ##################################################
        # Blocks
        ##################################################

        def _probe_control_probe():
            while True:
                val = self.bloc_probe_control.level()
                try:
                    self.set_probe_control(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (2e6))
        _probe_control_thread = threading.Thread(target=_probe_control_probe)
        _probe_control_thread.daemon = True
        _probe_control_thread.start()

        self.blocks_vector_source_x_0 = blocks.vector_source_c(parameter_0, True, 1, [])
        self.bloc_probe_control = blocks.probe_signal_b()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_vector_source_x_0, 0), (self, 0))
        self.connect((self, 0), (self.bloc_probe_control, 0))

    def get_parameter_0(self):
        return self.parameter_0

    def set_parameter_0(self, parameter_0):
        self.parameter_0 = parameter_0
        self.blocks_vector_source_x_0.set_data(self.parameter_0, [])

    def get_samp_rate(self):
        return self.samp_rate

    def set_samp_rate(self, samp_rate):
        self.samp_rate = samp_rate

    def get_probe_control(self):
        return self.probe_control

    def set_probe_control(self, probe_control):
        self.probe_control = probe_control

 Hier custom bloc which generates "Vector_Genator_C.py" Control signal (probe input) Original generated sequence Desired result (Controlled vector by probe)

非常感谢!! 扎克

0 个答案:

没有答案