Example #1
0
    def test_002_es_source (self):

        tb = gr.top_block();

        # create the arbiter shared memory space
        arb = es.es_make_arbiter();

        # create the source event queue
        queue = es.queue();

        # create the source block and set a max stream length on it
        src = es.source( arb, queue, [gr.sizeof_float] );
        src.set_max(20);
       
        # add a singular event
        vec = es.pmt_float_vector([1,2,3,4]);
        e1 = es.event_create_gen_vector_f( 3, vec );
        h1 = es.es_handler_insert_vector();
        h1p = es.make_handler_pmt( h1 );

        #e1 = es.es_make_event_gen_vector_f(arb, [1,2,3,4]);
        #e1.set_time(13)

        #print dir(es)
        #e1 = es.event_create( "test_event", 13, 4 );
        #e1 = es.event_create( "test_event", 13, 4 );
        queue.register_event_type( es.event_type( e1 ) );
        queue.bind_handler( es.event_type( e1 ), h1p );
        queue.add_event(e1);
        
        # set up a vector sink for printing
        snk = gr.vector_sink_f();
        tb.connect(src, snk);

        # run the graph to completion and print output stream
        tb.run();
        print snk.data();
Example #2
0
    def test_002_es_source(self):

        tb = gr.top_block()

        # create the arbiter shared memory space
        arb = es.es_make_arbiter()

        # create the source event queue
        queue = es.queue()

        # create the source block and set a max stream length on it
        src = es.source(arb, queue, [gr.sizeof_float])
        src.set_max(20)

        # add a singular event
        vec = es.pmt_float_vector([1, 2, 3, 4])
        e1 = es.event_create_gen_vector_f(3, vec)
        h1 = es.es_handler_insert_vector()
        h1p = es.make_handler_pmt(h1)

        # e1 = es.es_make_event_gen_vector_f(arb, [1,2,3,4]);
        # e1.set_time(13)

        # print dir(es)
        # e1 = es.event_create( "test_event", 13, 4 );
        # e1 = es.event_create( "test_event", 13, 4 );
        queue.register_event_type(es.event_type(e1))
        queue.bind_handler(es.event_type(e1), h1p)
        queue.add_event(e1)

        # set up a vector sink for printing
        snk = gr.vector_sink_f()
        tb.connect(src, snk)

        # run the graph to completion and print output stream
        tb.run()
        print snk.data()
def post_hook(val):
    blocks = val.handler.pb2();
    blocks["head_L"].reset();
    blocks["head_R"].reset();
    r = es.es_hook_rval();
    return r;

# define our new event handler
key_handler = es.es_pyhandler_def();
key_handler.set_pyfactory_cb(key_factory);
key_handler.set_pypre_hook_cb(pre_hook);
key_handler.set_pypost_hook_cb(post_hook);
key_handler_graph = es.es_handler_flowgraph( key_handler );

# set up some common es components
arb = es.es_make_arbiter();
queue = es.queue();
queue.set_early_behavior(1);

# set up the main flow graph
tb = gr.top_block();
src = es.source( arb, queue, [gr.sizeof_float, gr.sizeof_float] );
sink = audio.sink(int(fs));
tb.connect((src,0),(sink,0));
tb.connect((src,1),(sink,1));

fsnk = gr.file_sink(gr.sizeof_gr_complex, "keypad.out");
f2c = gr.float_to_complex();
tb.connect( (src,0), (f2c,0) , fsnk);
tb.connect( (src,1), (f2c,1) );
Example #4
0
# post hook, reset the head blocks' counters
def post_hook(val):
    #    val.handler.sink.clear();
    r = es.es_hook_rval()
    return r


# define our new event handler
key_handler = es.es_pyhandler_def()
key_handler.set_pyfactory_cb(key_factory)
key_handler.set_pypre_hook_cb(pre_hook)
#key_handler.set_pypost_hook_cb(post_hook);
key_handler_graph = es.es_handler_flowgraph(key_handler, 2)

# set up some common es components
arb = es.es_make_arbiter()
queue = es.queue()

# most packets will got out as scheduled
# but if we are ever later just send it as soon as possible
queue.set_early_behavior(1)
#queue.set_early_behavior(0);

# set up the main flow graph
tb = gr.top_block()
src = es.source(arb, queue, [gr.sizeof_gr_complex])
#sink = gr.file_sink(gr.sizeof_gr_complex , "outfile.dat" );
sink = gr.udp_sink(gr.sizeof_gr_complex, "localhost", 12345)
summer = gr.add_cc()
noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_amp)
throttle = gr.throttle(gr.sizeof_gr_complex, fs)