X1Sequence.cpp
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 /*
40 * X1Sequence.cpp
41 *
42 * GPS X1 Sequencer.
43 * Applied Research Laboratories, The University of Texas at Austin
44 * August 2003
45 */
46 
47  // Project headers
48 #include "Exception.hpp"
49 #include "X1Sequence.hpp"
50 #include "GenXSequence.hpp"
51 
52 namespace gnsstk
53 {
54  // Static Variable Definition
55  bool X1Sequence::isInit = false;
56  uint32_t* X1Sequence::X1Bits = 0;
57 
59  {
60  if (isInit!=true)
61  {
63  "Must call X1Sequence::allocateMemory() before instantiating a X1Sequence object.");
64  GNSSTK_THROW(e);
65  }
66  }
67 
69  {
70  int X1Aepoch;
71  int X1Acount;
72  int X1Bepoch;
73  int X1Bcount;
74  int X1epoch = 1;
75  long X1Word = 0;
76  int lengthOfX1BSequence;
77 
78  if (isInit==true)
79  {
80  gnsstk::Exception e ("X1Sequence::allocateMemory() called multiple times");
81  GNSSTK_THROW(e);
82  }
83 
84  X1Bits = new uint32_t[NUM_6SEC_WORDS];
85  if (X1Bits==0)
86  {
87  gnsstk::Exception e ("X1Sequence::allocateMemory() - allocation failed.");
88  GNSSTK_THROW(e);
89  }
90 
91  // Generate the X1A and X1B sequences.
94 
95  // Combination will be performed for four X1 epochs.
96  // This will generate six seconds of X1 bits sequence
97  // that will end on an even 32-bit boundary.
98  uint32_t X1Abits;
99  uint32_t X1Bbits;
100  X1Aepoch = 1;
101  X1Acount = 0;
102  X1Bepoch = 1;
103  X1Bcount = 0;
104  lengthOfX1BSequence = XB_COUNT;
105 
106  while ( X1Word < NUM_6SEC_WORDS )
107  {
108  // Get 32 X1A bits. Update counters and handle rollovers.
109  X1Abits = X1A[X1Acount];
110  X1Acount += MAX_BIT;
111 
112  if ( X1Acount >= XA_COUNT )
113  {
114  ++X1Aepoch;
115  if (X1Aepoch>XA_MAX_EPOCH)
116  {
117  ++X1epoch;
118  X1Aepoch = 1;
119  }
120  X1Acount = X1Acount - XA_COUNT;
121  }
122 
123  // Get 32 X1B bits. Update counters and handle rollovers
124  X1Bbits = X1B[X1Bcount];
125  X1Bcount += MAX_BIT;
126  if (X1Bcount >= lengthOfX1BSequence )
127  {
128  X1Bcount = X1Bcount - lengthOfX1BSequence;
129  ++X1Bepoch;
130  if (X1Bepoch>XB_MAX_EPOCH) X1Bepoch = 1;
131  if (X1Bepoch==XB_MAX_EPOCH)
132  lengthOfX1BSequence = XB_COUNT+XB_EPOCH_DELAY;
133  else
134  lengthOfX1BSequence = XB_COUNT;
135  X1B.setLengthOfSequence( lengthOfX1BSequence );
136  }
137 
138  X1Bits[X1Word++] = X1Abits ^ X1Bbits;
139  }
140 
141  isInit = true;
142  }
143 
145  {
146  if (isInit!=true || X1Bits==0)
147  {
148  gnsstk::Exception e("X1Sequence::deAllocateMemory() called when no memory allocated.");
149  GNSSTK_THROW(e);
150  }
151  delete [] X1Bits;
152  isInit = false;
153  }
154 
155 } // end of namespace
X1Sequence.hpp
gnsstk::X1B_INIT
const unsigned int X1B_INIT
Definition: PCodeConst.hpp:71
gnsstk::NUM_6SEC_WORDS
const long NUM_6SEC_WORDS
Number of 4 byte unsigned ints necessary to hold 6 sec of P-code.
Definition: PCodeConst.hpp:64
gnsstk::X1Sequence::deAllocateMemory
static void deAllocateMemory()
Definition: X1Sequence.cpp:144
gnsstk::X1Sequence::X1Bits
static uint32_t * X1Bits
Definition: X1Sequence.hpp:114
gnsstk::XB_EPOCH_DELAY
const long XB_EPOCH_DELAY
Definition: PCodeConst.hpp:94
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::XA_EPOCH_DELAY
const long XA_EPOCH_DELAY
Definition: PCodeConst.hpp:93
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::X1A_INIT
const unsigned int X1A_INIT
INIT variables are starting conditions of 12-bit registers (IS-GPS-200)
Definition: PCodeConst.hpp:70
gnsstk::X1A_TAPS
const unsigned int X1A_TAPS
TAPS variables denote which stages of 12-bit registers are XOR'd.
Definition: PCodeConst.hpp:76
gnsstk::X1Sequence::isInit
static bool isInit
Definition: X1Sequence.hpp:115
gnsstk::GenXSequence
Definition: GenXSequence.hpp:96
gnsstk::XA_COUNT
const int XA_COUNT
X?_COUNT is the number of bits in an epoch.
Definition: PCodeConst.hpp:86
gnsstk::X1Sequence::allocateMemory
static void allocateMemory()
Definition: X1Sequence.cpp:68
gnsstk::MAX_BIT
const int MAX_BIT
Number of bits assumed to be in a unsigned long int.
Definition: PCodeConst.hpp:55
Exception.hpp
GenXSequence.hpp
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::XB_MAX_EPOCH
const int XB_MAX_EPOCH
Definition: PCodeConst.hpp:83
gnsstk::GenXSequence::setLengthOfSequence
void setLengthOfSequence(int i)
Set the end of sequence for the current cycle.
Definition: GenXSequence.cpp:206
gnsstk::X1B_TAPS
const unsigned int X1B_TAPS
Definition: PCodeConst.hpp:77
gnsstk::XB_COUNT
const int XB_COUNT
Definition: PCodeConst.hpp:87
gnsstk::X1Sequence::X1Sequence
X1Sequence()
Definition: X1Sequence.cpp:58


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