Added gr-pager component to trunk by merging from r3474:r3537 in
[debian/gnuradio] / gr-pager / src / flex_demod.py
1 #
2 # Copyright 2006 Free Software Foundation, Inc.
3
4 # This file is part of GNU Radio
5
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
10
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING.  If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
20
21
22 from gnuradio import gr, optfir
23 from math import pi
24 import pager_swig
25
26 class flex_demod(gr.hier_block):
27     """
28     FLEX protocol demodulation block.
29
30     This block demodulates a band-limited, complex down-converted baseband 
31     channel into FLEX protocol frames.
32
33     Flow graph (so far):
34
35     QUAD     - Quadrature demodulator converts FSK to baseband amplitudes  
36     LPF      - Low pass filter to remove noise prior to slicer
37     SLICER   - Converts input to one of four symbols (0, 1, 2, 3)
38     DEFRAMER - Syncronizes symbol stream and outputs FLEX codewords
39     ---
40
41     @param fg: flowgraph
42     @param channel_rate:  incoming sample rate of the baseband channel
43     @type sample_rate: integer
44     """
45
46     def __init__(self, fg, channel_rate):
47         k = channel_rate/(2*pi*4800)        # 4800 Hz max deviation
48         QUAD = gr.quadrature_demod_cf(k)
49
50         taps = optfir.low_pass(1.0, channel_rate, 3200, 6400, 0.1, 60)
51         LPF = gr.fir_filter_fff(1, taps)
52         SLICER = pager_swig.slicer_fb(.001, .00001) # Attack, decay
53         DEFRAMER = pager_swig.flex_deframer(channel_rate)
54         
55         fg.connect(QUAD, LPF, SLICER, DEFRAMER)
56
57         gr.hier_block.__init__(self, fg, QUAD, DEFRAMER)