Example #1
0
    def test_003_es_sink (self):
        print "test_003_es_sink"
        iv = [0,1,2,3,4,5,6,7,8,9];
        src = blocks.vector_source_f(iv, repeat=True);
        hd = blocks.head(gr.sizeof_float, 10000);
        snk = es.sink([gr.sizeof_float], 8);
        t = es.trigger_sample_timer(gr.sizeof_float, 10, 5, 10, 10);
        tb = gr.top_block();
        pduh = es.es_make_handler_pdu(es.es_handler_print.TYPE_F32);
        msgdb = blocks.message_debug()
        tb.connect(src, hd, t, snk);   
        tb.msg_connect( t, "which_stream", snk, "schedule_event" )
        tb.msg_connect( t, "sample_timer_event", pduh, "handle_event" )
        tb.msg_connect( pduh, "pdus_out", msgdb, "store" )
        tb.run();
 
        # expected output of each event in the periodic sequence   
        sv = numpy.array( iv[5:] + iv[:5], dtype=numpy.float32 );

        # verify each received message
        nm = msgdb.num_messages();
        print "nm = %d"%(nm);
        for i in range(0, nm):
            m = msgdb.get_message(i);
            mp = pmt.to_python(pmt.cdr(m));
            print mp;
            self.assertEqual( sv.all(), mp.all() );
Example #2
0
 def test_001_alloc_things(self):
     print "test_001_alloc_things"
     b = []
     b.append(es.sink([1,1], 8))
     b.append(es.source([1], 8))
     b.append(es.es_handler_file( es.es_handler_file.TYPE_F32, "/dev/null", "test"))
     b.append(es.es_handler_insert_vector())
     b.append(es.es_handler_print(es.es_handler_print.TYPE_C32))
     b.append(es.es_handler_pdu(es.es_handler_pdu.TYPE_C32))
     b.append(es.trigger_edge_f(0, 100, 0, 1, 0))
     b.append(es.trigger_sample_timer(1, 1000, 0, 0, 100))