blob: 4f2045c5f68faecc38b72bc2c6f554e90cf16d16 [file] [log] [blame]
Piotr Krysik09826732016-07-15 13:14:24 +02001# -*- coding: utf-8 -*-
2##################################################
3# GNU Radio Python Flow Graph
Piotr Krysikd1ca3892016-07-17 11:33:50 +02004# Title: Clock offset corrector tagged
Piotr Krysik09826732016-07-15 13:14:24 +02005# Author: Piotr Krysik
6# Description: Clock offset corrector with blocks that use tags to switch offsets
Piotr Krysikd1ca3892016-07-17 11:33:50 +02007# Generated: Sun Jul 17 11:30:51 2016
Piotr Krysik09826732016-07-15 13:14:24 +02008##################################################
9
10from gnuradio import gr
11from gnuradio.filter import firdes
12import grgsm
13import math
14
15
16class 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 ##################################################
Piotr Krysikd1ca3892016-07-17 11:33:50 +020041 self.gsm_msg_to_tag_0 = grgsm.msg_to_tag()
Piotr Krysik09826732016-07-15 13:14:24 +020042 self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(ppm/1.0e6*2*math.pi*fc/samp_rate_in,samp_rate_out)
Piotr Krysikd1ca3892016-07-17 11:33:50 +020043 self.gsm_controlled_fractional_resampler_cc_0 = grgsm.controlled_fractional_resampler_cc(0, 1.0)
Piotr Krysik09826732016-07-15 13:14:24 +020044
45 ##################################################
46 # Connections
47 ##################################################
Piotr Krysikd1ca3892016-07-17 11:33:50 +020048 self.msg_connect((self, 'ctrl'), (self.gsm_msg_to_tag_0, 'msg'))
49 self.connect((self.gsm_controlled_fractional_resampler_cc_0, 0), (self.gsm_controlled_rotator_cc_0, 0))
Piotr Krysik09826732016-07-15 13:14:24 +020050 self.connect((self.gsm_controlled_rotator_cc_0, 0), (self, 0))
Piotr Krysikd1ca3892016-07-17 11:33:50 +020051 self.connect((self.gsm_msg_to_tag_0, 0), (self.gsm_controlled_fractional_resampler_cc_0, 0))
52 self.connect((self, 0), (self.gsm_msg_to_tag_0, 0))
Piotr Krysik09826732016-07-15 13:14:24 +020053
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)