Piotr Krysik | 0982673 | 2016-07-15 13:14:24 +0200 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | ################################################## |
| 3 | # GNU Radio Python Flow Graph |
| 4 | # Title: Clock offset corrector |
| 5 | # Author: Piotr Krysik |
| 6 | # Description: Clock offset corrector with blocks that use tags to switch offsets |
| 7 | # Generated: Fri Jul 15 10:09:22 2016 |
| 8 | ################################################## |
| 9 | |
| 10 | from gnuradio import gr |
| 11 | from gnuradio.filter import firdes |
| 12 | import grgsm |
| 13 | import math |
| 14 | |
| 15 | |
| 16 | class clock_offset_corrector_tagged(grgsm.hier_block): |
| 17 | |
| 18 | def __init__(self, fc=936.6e6, ppm=0, samp_rate_in=1625000.0/6.0*4.0): |
| 19 | gr.hier_block2.__init__( |
| 20 | self, "Clock offset corrector tagged", |
| 21 | gr.io_signature(1, 1, gr.sizeof_gr_complex*1), |
| 22 | gr.io_signature(1, 1, gr.sizeof_gr_complex*1), |
| 23 | ) |
| 24 | self.message_port_register_hier_in("ctrl") |
| 25 | |
| 26 | ################################################## |
| 27 | # Parameters |
| 28 | ################################################## |
| 29 | self.fc = fc |
| 30 | self.ppm = ppm |
| 31 | self.samp_rate_in = samp_rate_in |
| 32 | |
| 33 | ################################################## |
| 34 | # Variables |
| 35 | ################################################## |
| 36 | self.samp_rate_out = samp_rate_out = samp_rate_in |
| 37 | |
| 38 | ################################################## |
| 39 | # Blocks |
| 40 | ################################################## |
| 41 | self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(ppm/1.0e6*2*math.pi*fc/samp_rate_in,samp_rate_out) |
| 42 | self.grgsm_msg_to_tag_0 = grgsm.msg_to_tag() |
| 43 | self.grgsm_controlled_fractional_resampler_cc_0 = grgsm.controlled_fractional_resampler_cc(0, 1.0) |
| 44 | |
| 45 | ################################################## |
| 46 | # Connections |
| 47 | ################################################## |
| 48 | self.msg_connect((self, 'ctrl'), (self.grgsm_msg_to_tag_0, 'msg')) |
| 49 | self.connect((self.grgsm_controlled_fractional_resampler_cc_0, 0), (self.gsm_controlled_rotator_cc_0, 0)) |
| 50 | self.connect((self.grgsm_msg_to_tag_0, 0), (self.grgsm_controlled_fractional_resampler_cc_0, 0)) |
| 51 | self.connect((self.gsm_controlled_rotator_cc_0, 0), (self, 0)) |
| 52 | self.connect((self, 0), (self.grgsm_msg_to_tag_0, 0)) |
| 53 | |
| 54 | def get_fc(self): |
| 55 | return self.fc |
| 56 | |
| 57 | def set_fc(self, fc): |
| 58 | self.fc = fc |
| 59 | self.gsm_controlled_rotator_cc_0.set_phase_inc(self.ppm/1.0e6*2*math.pi*self.fc/self.samp_rate_in) |
| 60 | |
| 61 | def get_ppm(self): |
| 62 | return self.ppm |
| 63 | |
| 64 | def set_ppm(self, ppm): |
| 65 | self.ppm = ppm |
| 66 | self.gsm_controlled_rotator_cc_0.set_phase_inc(self.ppm/1.0e6*2*math.pi*self.fc/self.samp_rate_in) |
| 67 | |
| 68 | def get_samp_rate_in(self): |
| 69 | return self.samp_rate_in |
| 70 | |
| 71 | def set_samp_rate_in(self, samp_rate_in): |
| 72 | self.samp_rate_in = samp_rate_in |
| 73 | self.set_samp_rate_out(self.samp_rate_in) |
| 74 | self.gsm_controlled_rotator_cc_0.set_phase_inc(self.ppm/1.0e6*2*math.pi*self.fc/self.samp_rate_in) |
| 75 | |
| 76 | def get_samp_rate_out(self): |
| 77 | return self.samp_rate_out |
| 78 | |
| 79 | def set_samp_rate_out(self, samp_rate_out): |
| 80 | self.samp_rate_out = samp_rate_out |
| 81 | self.gsm_controlled_rotator_cc_0.set_samp_rate(self.samp_rate_out) |