def run(self): while(self.count == -1 or self.count > 0): time.sleep(self.delay); timer_evt = es.event_create(self.d_type, 0, self.evt_length); timer_evt = es.event_args_add( timer_evt, pmt.pmt_intern("timer_counter"), pmt.pmt_from_long(self.count)); self.queue.add_event( timer_evt ); if(self.count > 0): self.count = self.count - 1;
def keypress(event): print "evt running" if(event.keysym == 'Escape'): root.destroy(); x = event.char print x; key_evt = es.event_create("key-press", 0, int(100e-3 * fs) ); key_evt = es.event_args_add( key_evt, key_sym, pmt.pmt_intern(str(x)) ); queue.add_event( key_evt );
def keypress(event): print "evt running" if(event.keysym == 'Escape'): root.destroy(); x = event.char print x; key_evt = es.event_create("key-press", 0, int(100e-3 * fs) ); key_evt = es.event_args_add( key_evt, key_sym, pmt.intern(str(x)) ); queue.add_event( key_evt );
def run(self): while self.count == -1 or self.count > 0: time.sleep(self.delay) timer_evt = es.event_create(self.d_type, 0, self.evt_length) timer_evt = es.event_args_add(timer_evt, pmt.intern("timer_counter"), pmt.from_long(self.count)) try: self.message_port_pub(pmt.intern("which_stream"), timer_evt) except: return if self.count > 0: self.count = self.count - 1
def run(self): while (self.count == -1 or self.count > 0): time.sleep(self.delay) timer_evt = es.event_create(self.d_type, 0, self.evt_length) timer_evt = es.event_args_add(timer_evt, pmt.intern("timer_counter"), pmt.from_long(self.count)) try: self.message_port_pub(pmt.intern("which_stream"), timer_evt) except: return if (self.count > 0): self.count = self.count - 1
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) ); # 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):
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) 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())
#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); e1 = es.event_create("fg-event", 2, 3); e2 = es.event_create("fg-event", 8, 3); e3 = es.event_create("fg-event", 12, 3); queue.register_event_type( es.event_type( e1 ) ); queue.bind_handler( es.event_type( e1 ), es.make_handler_pmt(fgh) ); print "--------calling queue.add_event(e1)-------------"; queue.add_event( e1 ); queue.add_event( e2 ); queue.add_event( e3 ); print "--------calling tb.run()-------------"; tb.run(); print "python: tb.run() returned" print "sink.data() = %s"%(str( sink.data() ));
#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) e1 = es.event_create("fg-event", 2, 3) e2 = es.event_create("fg-event", 8, 3) e3 = es.event_create("fg-event", 12, 3) queue.register_event_type(es.event_type(e1)) queue.bind_handler(es.event_type(e1), es.make_handler_pmt(fgh)) print "--------calling queue.add_event(e1)-------------" queue.add_event(e1) queue.add_event(e2) queue.add_event(e3) print "--------calling tb.run()-------------" tb.run() print "python: tb.run() returned" print "sink.data() = %s" % (str(sink.data()))
def keypress(self, event): x = event.char print "KEYPRESS!: %s" % (x) key_evt = es.event_create(self.d_type, 0, self.evt_length) key_evt = es.event_args_add(key_evt, self.key_sym, pmt.intern(str(x))) self.queue.add_event(key_evt)
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) ); # create initial event, set up event bindings, handlers e1 = es.event_create("key-press", 10, evt_len ); tmp_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):
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); 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());