예제 #1
0
    def test_000(self):
        num_msgs = 10
        msg_interval = 1000
        msg_list = []
        for i in range(num_msgs):
            msg_list.append(pmt.pmt_from_long(i))

        # Create vector source with dummy data to trigger messages
        src_data = []
        for i in range(num_msgs * msg_interval):
            src_data.append(float(i))
        src = gr.vector_source_f(src_data, False)
        msg_gen = message_generator(msg_list, msg_interval)
        msg_cons = message_consumer()

        # Connect vector source to message gen
        self.tb.connect(src, msg_gen)

        # Connect message generator to message consumer
        self.tb.msg_connect(msg_gen, 'out_port', msg_cons, 'in_port')

        # Verify that the messgae port query functions work
        self.assertEqual(
            pmt.pmt_symbol_to_string(
                pmt.pmt_vector_ref(msg_gen.message_ports_out(), 0)),
            'out_port')
        self.assertEqual(
            pmt.pmt_symbol_to_string(
                pmt.pmt_vector_ref(msg_cons.message_ports_in(), 0)), 'in_port')

        # Run to verify message passing
        self.tb.start()

        # Wait for all messages to be sent
        while msg_gen.msg_ctr < num_msgs:
            time.sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        # Verify that the message consumer got all the messages
        self.assertEqual(num_msgs, len(msg_cons.msg_list))
        for i in range(num_msgs):
            self.assertTrue(pmt.pmt_equal(msg_list[i], msg_cons.msg_list[i]))
    def test_000(self):
        num_msgs = 10
        msg_interval = 1000
        msg_list = []
        for i in range(num_msgs):
            msg_list.append(pmt.pmt_from_long(i))

        # Create vector source with dummy data to trigger messages
        src_data = []
        for i in range(num_msgs*msg_interval):
            src_data.append(float(i))
        src = gr.vector_source_f(src_data, False)
        msg_gen = message_generator(msg_list, msg_interval)
        msg_cons = message_consumer()
        
        # Connect vector source to message gen
        self.tb.connect(src, msg_gen)
        
        # Connect message generator to message consumer
        self.tb.msg_connect(msg_gen, 'out_port', msg_cons, 'in_port')

        # Verify that the messgae port query functions work
        self.assertEqual(pmt.pmt_symbol_to_string(pmt.pmt_vector_ref(
                    msg_gen.message_ports_out(), 0)), 'out_port')
        self.assertEqual(pmt.pmt_symbol_to_string(pmt.pmt_vector_ref(
                    msg_cons.message_ports_in(), 0)), 'in_port')
        
        # Run to verify message passing
        self.tb.start()

        # Wait for all messages to be sent
        while msg_gen.msg_ctr < num_msgs:
            time.sleep(0.5)
        self.tb.stop()
        self.tb.wait()               
        
        # Verify that the message consumer got all the messages
        self.assertEqual(num_msgs, len(msg_cons.msg_list))
        for i in range(num_msgs):
            self.assertTrue(pmt.pmt_equal(msg_list[i], msg_cons.msg_list[i]))
예제 #3
0
def pmt_to_vector(p):
    v = list()
    for i in range(pmt.pmt_length(p)):
        elem = pmt.pmt_vector_ref(p, i)
        v.append(pmt_to_python(elem))
    return v
예제 #4
0
def pmt_to_vector(p):
    v = list()
    for i in range(pmt.pmt_length(p)):
        elem = pmt.pmt_vector_ref(p, i)
        v.append(pmt_to_python(elem))
    return v