blob: 87f5ab20f0f721449e931456968a365ebbbe8e3b [file] [log] [blame]
Alexander Chemeris040b3052013-06-16 14:29:54 +04001/*
2* Copyright 2008 Free Software Foundation, Inc.
3* Copyright 2011 Range Networks, Inc.
4*
5* This software is distributed under the terms of the GNU Affero Public License.
6* See the COPYING file in the main directory for details.
7*
8* This use of this software may be subject to additional restrictions.
9* See the LEGAL file in the main directory for details.
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU Affero General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU Affero General Public License for more details.
20
21 You should have received a copy of the GNU Affero General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
23
24*/
25
26
27#include "GSMCommon.h"
28
29using namespace GSM;
30using namespace std;
31
32
33const BitVector GSM::gTrainingSequence[] = {
34 BitVector("00100101110000100010010111"),
35 BitVector("00101101110111100010110111"),
36 BitVector("01000011101110100100001110"),
37 BitVector("01000111101101000100011110"),
38 BitVector("00011010111001000001101011"),
39 BitVector("01001110101100000100111010"),
40 BitVector("10100111110110001010011111"),
41 BitVector("11101111000100101110111100"),
42};
43
44const BitVector GSM::gDummyBurst("0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000");
45
46const BitVector GSM::gRACHSynchSequence("01001011011111111001100110101010001111000");
47
48
49int32_t GSM::FNDelta(int32_t v1, int32_t v2)
50{
51 static const int32_t halfModulus = gHyperframe/2;
52 int32_t delta = v1-v2;
53 if (delta>=halfModulus) delta -= gHyperframe;
54 else if (delta<-halfModulus) delta += gHyperframe;
55 return (int32_t) delta;
56}
57
58int GSM::FNCompare(int32_t v1, int32_t v2)
59{
60 int32_t delta = FNDelta(v1,v2);
61 if (delta>0) return 1;
62 if (delta<0) return -1;
63 return 0;
64}
65
66
67
68
69ostream& GSM::operator<<(ostream& os, const Time& t)
70{
71 os << t.TN() << ":" << t.FN();
72 return os;
73}
74
75
76// vim: ts=4 sw=4