00001 #pragma ident "$Id: X2Sequence.hpp 2943 2011-10-25 17:17:11Z yanweignss $"
00002
00003
00004
00005
00006 #ifndef X2SEQUENCE_HPP
00007 #define X2SEQUENCE_HPP
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #include "gpstkplatform.h"
00053 #include "PCodeConst.hpp"
00054 #include "mergePCodeWords.h"
00055
00056 namespace gpstk
00057 {
00060
00061
00062
00063
00064
00065 const long LENGTH_OF_EOW_OVERLAP = 34;
00066 const long OVERLAP_WORD_POSITION = 1451897;
00067
00068 const long MAX_X2_TEST = 4 * ((XA_COUNT * XA_MAX_EPOCH) + X2A_EPOCH_DELAY);
00069
00070 const long MAX_X2_COUNT = X2A_EPOCH_DELAY + MAX_X2_TEST;
00071
00142 class X2Sequence
00143 {
00144 public:
00150 X2Sequence();
00151 ~X2Sequence( ) {};
00152
00170 static void allocateMemory( );
00171 static void deAllocateMemory( );
00172
00185 uint32_t operator[]( long i );
00186
00191 void setEOWX2Epoch( const bool tf );
00192
00193 private:
00194 uint32_t *bitsP;
00195 static uint32_t* X2Bits;
00196 static uint32_t* X2BitsEOW;
00197 static uint32_t EOWEndOfSequence[LENGTH_OF_EOW_OVERLAP];
00198 static bool isInit;
00199 };
00200
00201
00202
00203
00204
00205
00206 inline uint32_t X2Sequence::operator[] ( long i )
00207 {
00208 long adjustedCount = i + X2A_EPOCH_DELAY;
00209
00210 uint32_t retArg = 0L;
00211 int ndx1 = adjustedCount / MAX_BIT;
00212 int offset = adjustedCount - (ndx1 * MAX_BIT);
00213 if ( (adjustedCount+MAX_BIT) <= MAX_X2_COUNT )
00214 {
00215 if (offset==0) retArg = bitsP[ndx1];
00216 else retArg = merge( bitsP[ndx1], bitsP[ndx1+1], offset );
00217 }
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 else
00241 {
00242 int numRemainingInSequence = MAX_X2_COUNT - adjustedCount;
00243 int numRemainingInWord;
00244 int numFilled = 0;
00245
00246
00247 if (ndx1==NUM_X2_WORDS-2)
00248 {
00249 numRemainingInWord = MAX_BIT - offset;
00250 retArg = bitsP[ndx1++] << offset;
00251 numFilled = numRemainingInWord;
00252 numRemainingInSequence -= numRemainingInWord;
00253 }
00254
00255
00256 uint32_t temp = bitsP[ndx1];
00257 numRemainingInWord = numRemainingInSequence;
00258 temp >>= (MAX_BIT-numRemainingInWord);
00259 temp <<= (MAX_BIT-(numRemainingInWord+numFilled));
00260 retArg |= temp;
00261 numFilled += numRemainingInSequence;
00262
00263
00264
00265 numRemainingInWord = (2 * MAX_BIT) - X2A_EPOCH_DELAY;
00266 int numNeeded = MAX_BIT - numFilled;
00267
00268
00269
00270 if (numNeeded <= numRemainingInWord)
00271 {
00272 temp = bitsP[1] << (MAX_BIT - numRemainingInWord);
00273 temp >>= (MAX_BIT - numNeeded);
00274 retArg |= temp;
00275 }
00276
00277 else
00278 {
00279
00280 temp = bitsP[1] << (MAX_BIT - numRemainingInWord);
00281 temp >>= (MAX_BIT - numRemainingInWord);
00282 temp <<= (MAX_BIT - (numRemainingInWord+numFilled));
00283 retArg |= temp;
00284
00285
00286 numFilled += numRemainingInWord;
00287 numNeeded = MAX_BIT - numFilled;
00288 temp = bitsP[2] >> (MAX_BIT - numNeeded);
00289 retArg |= temp;
00290 }
00291 }
00292 return(retArg);
00293 }
00295 }
00296
00297 #endif // X2SEQUENCE_HPP