Piotr Krysik | 8d7b64d | 2017-11-08 14:34:02 +0100 | [diff] [blame] | 1 | """ |
| 2 | Embedded Python Blocks: |
| 3 | |
| 4 | Each this file is saved, GRC will instantiate the first class it finds to get |
| 5 | ports and parameters of your block. The arguments to __init__ will be the |
| 6 | parameters. All of them are required to have default values! |
| 7 | """ |
| 8 | import numpy as np |
| 9 | from gnuradio import gr |
| 10 | import pmt |
| 11 | |
| 12 | class burst_to_fn_time(gr.basic_block): |
| 13 | def __init__(self): # only default arguments here |
| 14 | gr.basic_block.__init__( |
| 15 | self, |
| 16 | name='Burst to fn_time', |
| 17 | in_sig=[], |
| 18 | out_sig=[] |
| 19 | ) |
| 20 | self.message_port_register_in(pmt.intern("bursts_in")) |
| 21 | self.message_port_register_out(pmt.intern("fn_time_out")) |
| 22 | self.set_msg_handler(pmt.intern("bursts_in"), self.convert) |
| 23 | |
| 24 | def convert(self, msg): |
| 25 | fn_time = pmt.dict_ref(pmt.car(msg),pmt.intern("fn_time"),pmt.PMT_NIL) |
| 26 | fn_time_msg = pmt.dict_add(pmt.make_dict(), pmt.intern("fn_time"), fn_time) |
| 27 | if pmt.to_python(fn_time) is not None: |
| 28 | self.message_port_pub(pmt.intern("fn_time_out"), fn_time_msg) |