예제 #1
0
    def test_basic_types(self):
        self.assertEqual(42, pmt.to_python(pmt.pmt_from_long(42)))
        self.assertTrue(pmt.pmt_equal(pmt.pmt_from_long(42), pmt.from_python(42)))

        self.assertEqual(4.2, pmt.to_python(pmt.pmt_from_double(4.2)))
        self.assertTrue(pmt.pmt_equal(pmt.pmt_from_double(4.2), pmt.from_python(4.2)))

        self.loopback(None)
        self.loopback(42)
        self.loopback(4.2)
        self.loopback(4.2j)
        self.loopback("42")
예제 #2
0
    def test_basic_types(self):
        self.assertEqual(42, pmt.to_python(pmt.pmt_from_long(42)))
        self.assertTrue(
            pmt.pmt_equal(pmt.pmt_from_long(42), pmt.from_python(42)))

        self.assertEqual(4.2, pmt.to_python(pmt.pmt_from_double(4.2)))
        self.assertTrue(
            pmt.pmt_equal(pmt.pmt_from_double(4.2), pmt.from_python(4.2)))

        self.loopback(None)
        self.loopback(42)
        self.loopback(4.2)
        self.loopback(4.2j)
        self.loopback("42")
예제 #3
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]))
예제 #5
0
 def test_null(self):
     self.assertEqual(None, pmt.to_python(pmt.PMT_NIL))
     self.assertTrue(pmt.pmt_equal(pmt.PMT_NIL, pmt.from_python(None)))
예제 #6
0
 def test_null(self):
     self.assertEqual(None, pmt.to_python(pmt.PMT_NIL))
     self.assertTrue(pmt.pmt_equal(pmt.PMT_NIL, pmt.from_python(None)))