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 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()
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) ); # create initial event, set up event bindings, handlers e1 = es.event_create("key-press", 10, evt_len ); tmp_pmt = pmt.pmt_intern("1"); print tmp_pmt; e1 = es.event_args_add( e1, key_sym, tmp_pmt ); queue.register_event_type( es.event_type( e1 ) ); queue.bind_handler( es.event_type( e1 ), es.make_handler_pmt(key_handler_graph) ); #queue.add_event( e1 ); # start the main flowgraph tb.start(); import Tkinter as tk; import sys; def keypress(event): print "evt running" if(event.keysym == 'Escape'): root.destroy(); x = event.char
# 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) tb.connect(src, summer, sink) tb.connect(noise, throttle, (summer, 1)) # create initial event, set up event bindings, handlers e1 = es.event_create("burst_transmit", 10, 1000) e1 = es.event_args_add(e1, key_sym, pmt.intern("1")) queue.register_event_type(es.event_type(e1)) queue.bind_handler(es.event_type(e1), es.make_handler_pmt(key_handler_graph)) # start the main flowgraph tb.start() import Tkinter as tk import sys import subprocess while (True): time.sleep(0.2 * random.random()) print "queue length = %d" % (queue.length()) # if we have a backlog waiting to go out go back to sleep if (queue.length() > 4):