From a1a871ee37959564107fac5b7c1278269418b946 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Fri, 21 Dec 2018 06:27:29 +0700 Subject: python/trx: rename 'change_sign_of_dict_elements' to 'dict_toggle_sign' The old name was quite long, resulting into cumbersome imports: from change_sign_of_dict_elements import change_sign_of_dict_elements let's use a shorter variant: from dict_toggle_sign import dict_toggle_sign Change-Id: Ie75e1d6e5e74c7c1cf34154633c1472e4b85dbb6 --- python/trx/CMakeLists.txt | 2 +- python/trx/__init__.py | 2 +- python/trx/change_sign_of_dict_elements.py | 30 ------------------------------ python/trx/dict_toggle_sign.py | 30 ++++++++++++++++++++++++++++++ python/trx/radio_if_grc.py | 8 ++++---- 5 files changed, 36 insertions(+), 36 deletions(-) delete mode 100644 python/trx/change_sign_of_dict_elements.py create mode 100644 python/trx/dict_toggle_sign.py diff --git a/python/trx/CMakeLists.txt b/python/trx/CMakeLists.txt index c6e3010..ffe5234 100644 --- a/python/trx/CMakeLists.txt +++ b/python/trx/CMakeLists.txt @@ -26,6 +26,6 @@ GR_PYTHON_INSTALL( fake_pm.py radio_if.py radio_if_grc.py - change_sign_of_dict_elements.py + dict_toggle_sign.py DESTINATION ${GR_PYTHON_DIR}/grgsm/trx ) diff --git a/python/trx/__init__.py b/python/trx/__init__.py index 372f46b..fda783e 100644 --- a/python/trx/__init__.py +++ b/python/trx/__init__.py @@ -26,4 +26,4 @@ from ctrl_if_bb import ctrl_if_bb from fake_pm import fake_pm from radio_if_grc import radio_if_grc from radio_if import radio_if -from change_sign_of_dict_elements import change_sign_of_dict_elements +from dict_toggle_sign import dict_toggle_sign diff --git a/python/trx/change_sign_of_dict_elements.py b/python/trx/change_sign_of_dict_elements.py deleted file mode 100644 index fd7c585..0000000 --- a/python/trx/change_sign_of_dict_elements.py +++ /dev/null @@ -1,30 +0,0 @@ -""" -Embedded Python Blocks: - -Each this file is saved, GRC will instantiate the first class it finds to get -ports and parameters of your block. The arguments to __init__ will be the -parameters. All of them are required to have default values! -""" - -from gnuradio import gr -from pmt import * - -class change_sign_of_dict_elements(gr.basic_block): - def __init__(self): # only default arguments here - gr.basic_block.__init__( - self, - name='Change sign of elts in dict', - in_sig=[], - out_sig=[] - ) - self.message_port_register_in(intern("dict_in")) - self.message_port_register_out(intern("dict_out")) - self.set_msg_handler(intern("dict_in"), self.change_sign) - - def change_sign(self, msg): - if is_dict(msg): - d = to_python(msg) - #print d - for key, value in d.items(): - d[key] *= -1 - self.message_port_pub(intern("dict_out"), to_pmt(d)) diff --git a/python/trx/dict_toggle_sign.py b/python/trx/dict_toggle_sign.py new file mode 100644 index 0000000..d6cd8bd --- /dev/null +++ b/python/trx/dict_toggle_sign.py @@ -0,0 +1,30 @@ +""" +Embedded Python Blocks: + +Each this file is saved, GRC will instantiate the first class it finds to get +ports and parameters of your block. The arguments to __init__ will be the +parameters. All of them are required to have default values! +""" + +from gnuradio import gr +from pmt import * + +class dict_toggle_sign(gr.basic_block): + def __init__(self): # only default arguments here + gr.basic_block.__init__( + self, + name='Change sign of elts in dict', + in_sig=[], + out_sig=[] + ) + self.message_port_register_in(intern("dict_in")) + self.message_port_register_out(intern("dict_out")) + self.set_msg_handler(intern("dict_in"), self.change_sign) + + def change_sign(self, msg): + if is_dict(msg): + d = to_python(msg) + #print d + for key, value in d.items(): + d[key] *= -1 + self.message_port_pub(intern("dict_out"), to_pmt(d)) diff --git a/python/trx/radio_if_grc.py b/python/trx/radio_if_grc.py index 920b0c5..8a92f6e 100755 --- a/python/trx/radio_if_grc.py +++ b/python/trx/radio_if_grc.py @@ -8,7 +8,7 @@ # Generated: Fri Dec 1 10:49:25 2017 ################################################## -from change_sign_of_dict_elements import change_sign_of_dict_elements +from dict_toggle_sign import dict_toggle_sign from gnuradio import blocks from gnuradio import digital from gnuradio import eng_notation @@ -94,16 +94,16 @@ class radio_if_grc(gr.top_block): self.gsm_burst_type_filter_0 = grgsm.burst_type_filter(([3])) self.gsm_burst_to_fn_time_0 = grgsm.burst_to_fn_time() self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc((firdes.window(firdes.WIN_HANN, 16, 0)), 0, 20, False, "packet_len") - self.change_sign_of_dict_elements = change_sign_of_dict_elements() + self.dict_toggle_sign = dict_toggle_sign() self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") ################################################## # Connections ################################################## - self.msg_connect((self.change_sign_of_dict_elements, 'dict_out'), (self.gsm_msg_to_tag_0_0, 'msg')) + self.msg_connect((self.dict_toggle_sign, 'dict_out'), (self.gsm_msg_to_tag_0_0, 'msg')) self.msg_connect((self.gsm_burst_to_fn_time_0, 'fn_time_out'), (self.gsm_txtime_setter_0, 'fn_time')) self.msg_connect((self.gsm_burst_type_filter_0, 'bursts_out'), (self.gsm_burst_to_fn_time_0, 'bursts_in')) - self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.change_sign_of_dict_elements, 'dict_in')) + self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.dict_toggle_sign, 'dict_in')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_msg_to_tag_0, 'msg')) self.msg_connect((self.gsm_preprocess_tx_burst_0, 'bursts_out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_burst_type_filter_0, 'bursts_in')) -- cgit v1.2.3