Alexander Chemeris | 040b305 | 2013-06-16 14:29:54 +0400 | [diff] [blame^] | 1 | /* |
| 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 | |
| 29 | using namespace GSM; |
| 30 | using namespace std; |
| 31 | |
| 32 | |
| 33 | const 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 | |
| 44 | const BitVector GSM::gDummyBurst("0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000"); |
| 45 | |
| 46 | const BitVector GSM::gRACHSynchSequence("01001011011111111001100110101010001111000"); |
| 47 | |
| 48 | |
| 49 | int32_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 | |
| 58 | int 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 | |
| 69 | ostream& 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 |