blocks["src_L"].set_frequency(rowfreqs[row]); blocks["src_R"].set_frequency(colfreqs[col]); print "set freq %s"%( str((rowfreqs[row], colfreqs[col])) ); r = es.es_hook_rval(); return r; # post hook, reset the head blocks' counters 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, r.sink); r.tb = tb.to_top_block(); r.blocks["src"] = src.to_basic_block(); return r; # Create our hook callback to be run before and after event flowgraph execution def hook_cb(args): print "TEST HOOK CB Called with %s :: %s"%(type(args), str(args)); print args.bufs; print args.msg; print args.blocks.keys(); r = es.es_hook_rval(); return r; ph = es.es_pyhandler_def(); ph.set_pyfactory_cb(factory_cb); #ph.set_pypre_hook_cb(hook_cb); #ph.set_pypost_hook_cb(hook_cb); fgh = es.es_handler_flowgraph( ph, 1 ); arb = es.es_make_arbiter(); queue = es.queue(); tb = gr.top_block(); src = es.source( arb, queue, [1] ); sink = gr.vector_sink_b(); src.set_max(20); tb.connect(src,sink);
v = numpy.fromstring(payload, dtype=numpy.byte) blocks = val.handler.pb2() blocks["src"].set_data(es.StrVector([payload]), len(v)) r = es.es_hook_rval() return r # 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
r.tb = tb.to_top_block() r.blocks["src"] = src.to_basic_block() return r # Create our hook callback to be run before and after event flowgraph execution def hook_cb(args): print "TEST HOOK CB Called with %s :: %s" % (type(args), str(args)) print args.bufs print args.msg print args.blocks.keys() r = es.es_hook_rval() return r ph = es.es_pyhandler_def() ph.set_pyfactory_cb(factory_cb) #ph.set_pypre_hook_cb(hook_cb); #ph.set_pypost_hook_cb(hook_cb); fgh = es.es_handler_flowgraph(ph, 1) arb = es.es_make_arbiter() queue = es.queue() tb = gr.top_block() src = es.source(arb, queue, [1]) sink = gr.vector_sink_b() src.set_max(20) tb.connect(src, sink)