X2Sequence.hpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
39 // X2Sequence.hpp - GPS X2 Sequencer
40 
41 #ifndef X2SEQUENCE_HPP
42 #define X2SEQUENCE_HPP
43 
44  // Local headers
45 #include "gnsstkplatform.h"
46 #include "PCodeConst.hpp"
47 #include "mergePCodeWords.h"
48 
49 namespace gnsstk
50 {
52 
53 
54  /*
55  The following constants are derived in x2EOW.cpp and
56  used as literals here.
57  */
58  const long LENGTH_OF_EOW_OVERLAP = 34;
59  const long OVERLAP_WORD_POSITION = 1451897;
60  // Maximum number of X2 chips (exclusive of BOW delay chips)
62  // Maximum number of X2 chips
64 
136  {
137  public:
143  X2Sequence();
144  ~X2Sequence( ) {};
145 
163  static void allocateMemory( );
164  static void deAllocateMemory( );
165 
178  uint32_t operator[]( long i );
179 
184  void setEOWX2Epoch( const bool tf );
185 
186  private:
187  uint32_t *bitsP;
188  static uint32_t* X2Bits;
189  static uint32_t* X2BitsEOW;
191  static bool isInit;
192  };
193 
194  /*
195  Given a bit position within the X2 sequence (numbered starting at -37),
196  return the next 32 bits. Note: if there are insufficient bits left
197  to fill the request, wrap around to the beginning of the sequence.
198  */
199  inline uint32_t X2Sequence::operator[] ( long i )
200  {
201  long adjustedCount = i + X2A_EPOCH_DELAY;
202 
203  uint32_t retArg = 0L;
204  int ndx1 = adjustedCount / MAX_BIT;
205  int offset = adjustedCount - (ndx1 * MAX_BIT);
206  if ( (adjustedCount+MAX_BIT) <= MAX_X2_COUNT )
207  {
208  if (offset==0) retArg = bitsP[ndx1];
209  else retArg = merge( bitsP[ndx1], bitsP[ndx1+1], offset );
210  }
211  /*
212  Complicated case when coming up to end of sequence. May have to
213  put together parts of up to three words to get 32 bits. The problem
214  is complicated because the word at the end of the array is partial
215  AND the beginning of sequence (BOW) occurs in mid-word due to the
216  PRN offset. Some numbers:
217 
218  Number of bits available in word N : 25
219  Number of bits available in word at BOS : 27
220 
221  Possible cases:
222  1.) Combine bits from [n-1], [n], and [BOS] - word n will provide
223  25 bits. Therefore, some combination of (n-1,BOS) from the
224  choice of (1,4), (2,3), (3,2), (4,1).
225 
226  2.) Combine bits from [n-1] and [BOS] - word n-1 will provide 25-5
227  bits. Therefore, BOS will provide 7-27 bits.
228 
229  3.) Combine bits from [n-1], [BOS], and [BOS+1] - word n-1 provides
230  4-1 bits. BOS provides 27 bits (running total to 31-28 bits).
231  BOS+1 provides 1-4 bits.
232  */
233  else
234  {
235  int numRemainingInSequence = MAX_X2_COUNT - adjustedCount;
236  int numRemainingInWord;
237  int numFilled = 0;
238 
239  // Handle word n-1
240  if (ndx1==NUM_X2_WORDS-2)
241  {
242  numRemainingInWord = MAX_BIT - offset;
243  retArg = bitsP[ndx1++] << offset;
244  numFilled = numRemainingInWord;
245  numRemainingInSequence -= numRemainingInWord;
246  }
247 
248  // Handle word n
249  uint32_t temp = bitsP[ndx1];
250  numRemainingInWord = numRemainingInSequence;
251  temp >>= (MAX_BIT-numRemainingInWord);
252  temp <<= (MAX_BIT-(numRemainingInWord+numFilled));
253  retArg |= temp;
254  numFilled += numRemainingInSequence;
255 
256  // Wrap to front. Recall that "front" is actually bit
257  // 37 in sequence due to "beginning of week" delay
258  numRemainingInWord = (2 * MAX_BIT) - X2A_EPOCH_DELAY;
259  int numNeeded = MAX_BIT - numFilled;
260 
261  // Case where all bits needed are in word 1 of sequence array
262  //(which only has 27 "useful" bits)
263  if (numNeeded <= numRemainingInWord)
264  {
265  temp = bitsP[1] << (MAX_BIT - numRemainingInWord);
266  temp >>= (MAX_BIT - numNeeded);
267  retArg |= temp;
268  }
269  // Case where all bits in word 1 are needed plus some bits in word 2.
270  else
271  {
272  // Clearing high-order bits
273  temp = bitsP[1] << (MAX_BIT - numRemainingInWord);
274  temp >>= (MAX_BIT - numRemainingInWord);
275  temp <<= (MAX_BIT - (numRemainingInWord+numFilled));
276  retArg |= temp;
277 
278  // Fetch remaining bits from next word
279  numFilled += numRemainingInWord;
280  numNeeded = MAX_BIT - numFilled;
281  temp = bitsP[2] >> (MAX_BIT - numNeeded);
282  retArg |= temp;
283  }
284  }
285  return(retArg);
286  }
288 } // end of namespace
289 
290 #endif // X2SEQUENCE_HPP
gnsstk::X2Sequence::deAllocateMemory
static void deAllocateMemory()
Definition: X2Sequence.cpp:220
gnsstk::X2A_EPOCH_DELAY
const long X2A_EPOCH_DELAY
The 37 chip delay at the end of every X2A epoch.
Definition: PCodeConst.hpp:97
gnsstk::NUM_X2_WORDS
const long NUM_X2_WORDS
Number of 4 byte unsigned ints necessary to hold an X2 sequence (with leading delay)
Definition: PCodeConst.hpp:67
gnsstk::MAX_X2_COUNT
const long MAX_X2_COUNT
Definition: X2Sequence.hpp:63
gnsstkplatform.h
gnsstk::X2Sequence
Definition: X2Sequence.hpp:135
gnsstk::MAX_X2_TEST
const long MAX_X2_TEST
Definition: X2Sequence.hpp:61
gnsstk::X2Sequence::X2Bits
static uint32_t * X2Bits
Definition: X2Sequence.hpp:188
gnsstk::XA_MAX_EPOCH
const int XA_MAX_EPOCH
X?_MAX_EPOCH is the maximum number of epochs in a sequence.
Definition: PCodeConst.hpp:82
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::X2Sequence::setEOWX2Epoch
void setEOWX2Epoch(const bool tf)
Definition: X2Sequence.cpp:232
example4.temp
temp
Definition: example4.py:35
gnsstk::X2Sequence::bitsP
uint32_t * bitsP
Definition: X2Sequence.hpp:187
gnsstk::LENGTH_OF_EOW_OVERLAP
const long LENGTH_OF_EOW_OVERLAP
Definition: X2Sequence.hpp:58
gnsstk::X2Sequence::~X2Sequence
~X2Sequence()
Definition: X2Sequence.hpp:144
mergePCodeWords.h
gnsstk::X2Sequence::operator[]
uint32_t operator[](long i)
Definition: X2Sequence.hpp:199
gnsstk::X2Sequence::isInit
static bool isInit
Definition: X2Sequence.hpp:191
gnsstk::XA_COUNT
const int XA_COUNT
X?_COUNT is the number of bits in an epoch.
Definition: PCodeConst.hpp:86
merge
uint32_t merge(uint32_t w1, uint32_t w2, int first_bit)
Definition: mergePCodeWords.h:52
gnsstk::MAX_BIT
const int MAX_BIT
Number of bits assumed to be in a unsigned long int.
Definition: PCodeConst.hpp:55
gnsstk::X2Sequence::X2BitsEOW
static uint32_t * X2BitsEOW
Definition: X2Sequence.hpp:189
gnsstk::X2Sequence::X2Sequence
X2Sequence()
Definition: X2Sequence.cpp:74
PCodeConst.hpp
gnsstk::X2Sequence::EOWEndOfSequence
static uint32_t EOWEndOfSequence[LENGTH_OF_EOW_OVERLAP]
Definition: X2Sequence.hpp:190
gnsstk::OVERLAP_WORD_POSITION
const long OVERLAP_WORD_POSITION
Definition: X2Sequence.hpp:59
gnsstk::X2Sequence::allocateMemory
static void allocateMemory()
Definition: X2Sequence.cpp:88


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:42