Пример #1
0
    def test_float(self):
        self.emitter = pdu_utils.message_emitter()
        self.down = pdu_utils.pdu_downsample(3, 0)
        self.debug = blocks.message_debug()
        self.tb.msg_connect((self.emitter, 'msg'), (self.down, 'pdu_in'))
        self.tb.msg_connect((self.down, 'pdu_out'), (self.debug, 'store'))

        i_vec = pmt.init_f32vector(9, [0, 1, 2, 3.3, 4, 5, 6, 7, 8])
        e_vec = pmt.init_f32vector(3, [0, 3.3, 6])
        in_pdu = pmt.cons(pmt.make_dict(), i_vec)
        e_pdu = pmt.cons(pmt.make_dict(), e_vec)

        self.tb.start()
        time.sleep(.001)
        self.emitter.emit(in_pdu)
        time.sleep(.01)
        self.tb.stop()
        self.tb.wait()

        print "test float:"
        print "pdu expected: " + repr(pmt.car(e_pdu))
        print "pdu got:      " + repr(pmt.car(self.debug.get_message(0)))
        print "data expected: " + repr(pmt.f32vector_elements(pmt.cdr(e_pdu)))
        print "data got:      " + repr(
            pmt.f32vector_elements(pmt.cdr(self.debug.get_message(0))))
        print

        self.assertTrue(pmt.equal(self.debug.get_message(0), e_pdu))
Пример #2
0
    def test_c32vector(self):
        '''
        Note: this is a negative test. Modules doesn't support c32vector, so this is testing that
        '''
        self.down = pdu_utils.pdu_downsample(3, 0)
        self.connectUp()

        i_vec = pmt.init_c32vector(3, [3 + 4j, 1 + 0j, 0 + 1j])
        in_pdu = pmt.cons(pmt.make_dict(), i_vec)

        self.tb.start()
        time.sleep(.001)
        self.emitter.emit(in_pdu)
        time.sleep(.01)
        self.tb.stop()
        self.tb.wait()

        self.assertEqual(0, self.debug.num_messages())
Пример #3
0
    def test_float(self):
        self.down = pdu_utils.pdu_downsample(3, 0)
        self.connectUp()

        i_vec = pmt.init_f32vector(9, [0, 1, 2, 3.3, 4, 5, 6, 7, 8])
        e_vec = pmt.init_f32vector(3, [0, 3.3, 6])
        in_pdu = pmt.cons(pmt.make_dict(), i_vec)
        e_pdu = pmt.cons(pmt.make_dict(), e_vec)

        self.tb.start()
        time.sleep(.001)
        self.emitter.emit(in_pdu)
        time.sleep(.01)
        self.tb.stop()
        self.tb.wait()

        print("test float:")
        print("pdu expected: " + repr(pmt.car(e_pdu)))
        print("pdu got:      " + repr(pmt.car(self.debug.get_message(0))))
        print("data expected: " + repr(pmt.f32vector_elements(pmt.cdr(e_pdu))))
        print("data got:      " + repr(pmt.f32vector_elements(pmt.cdr(self.debug.get_message(0)))))
        print

        self.assertTrue(pmt.equal(self.debug.get_message(0), e_pdu))