00001
00002
00003
00004
00005
00006
00007
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 #include <stdlib.h>
00035 #include <stdio.h>
00036 #include <map>
00037
00038
00039 #include "PCodeConst.hpp"
00040 #include "SVPCodeGen.hpp"
00041 #include "CodeBuffer.hpp"
00042 #include "X1Sequence.hpp"
00043 #include "X2Sequence.hpp"
00044
00050 using namespace std;
00051 using namespace gpstk;
00052
00053
00054
00055
00056 struct SVData
00057 {
00058 SVPCodeGen * PCodeGen;
00059 CodeBuffer * PCodeBuf;
00060 codeType cType;
00061 SVData( SVPCodeGen * a1,
00062 CodeBuffer * a2,
00063 codeType c )
00064 {
00065 PCodeGen = a1;
00066 PCodeBuf = a2;
00067 cType = c;
00068 };
00069 };
00070
00071 const int NUM_SATS = 38;
00072
00073 int main(int argc, char* argv[] )
00074 {
00075 printf("Ryan's Xendweek\n");
00076
00077 if (argc < 2)
00078 {
00079 printf("Usage: >>Xendweek <outputfile>\n");
00080 exit(1);
00081 }
00082
00083 printf(" Opening output file.\n");
00084 FILE *outFile = fopen( argv[1], "wt" );
00085 if (outFile==NULL)
00086 {
00087 printf(" Cannot open Xendweek.out for output.\n");
00088 exit(-1);
00089 }
00090 fprintf(outFile," XENDWEEK.OUT - Demonstrating P-Code End of Week Generation..\n");
00091 fprintf(outFile," Reproducing ICD-GPS-200, Table 3-IV\n");
00092
00093
00094 printf(" Setting time to end of week.\n");
00095
00096 DayTime dt( 1233, 604794.0 );
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 try
00108 {
00109 X1Sequence::allocateMemory();
00110 X2Sequence::allocateMemory();
00111 }
00112 catch (gpstk::Exception e)
00113 {
00114 printf(" Memory allocation failure.\n");
00115 printf(" Xbegweek will terminate.\n");
00116 return(1);
00117 }
00118
00119
00120 printf(" Instantiating the PRN map.\n");
00121 map<int, SVData>svdMap;
00122 typedef map<int, SVData>::iterator SVDataI;
00123
00124
00125 SVPCodeGen * svp[NUM_SATS];
00126 CodeBuffer * pcb[NUM_SATS];
00127 for (int n=0;n<NUM_SATS;++n) { svp[n]=0; pcb[n]=0; };
00128
00129 for (int PRNndx=0; PRNndx<NUM_SATS; ++PRNndx)
00130 {
00131 svp[PRNndx] = new SVPCodeGen( PRNndx, dt );
00132 pcb[PRNndx] = new CodeBuffer( PRNndx );
00133
00134 SVData svd( svp[PRNndx], pcb[PRNndx], P_CODE );
00135 pair<int,SVData> ps( PRNndx, svd );
00136 svdMap.insert( ps );
00137 }
00138
00139 fprintf(outFile," PRN Last word ");
00140
00141
00142 long EndOfWeekTestCount =
00143 3 * (XA_COUNT * XA_MAX_EPOCH) + (XA_COUNT * (XA_MAX_EPOCH-1)) + 3023;
00144 long EndOfWeekTestWord = (EndOfWeekTestCount / MAX_BIT);
00145 long EndOfWeekTestEnd = EndOfWeekTestWord+(XA_EPOCH_DELAY+104)/MAX_BIT+3;
00146
00147 long chip = EndOfWeekTestWord * MAX_BIT -
00148 3 * (XA_COUNT * XA_MAX_EPOCH) - (XA_COUNT * (XA_MAX_EPOCH-1));
00149 for (long j=EndOfWeekTestWord;j<EndOfWeekTestEnd;j++)
00150 {
00151 fprintf(outFile,"%4d ",chip);
00152 chip+=32;
00153 }
00154 fprintf(outFile,"\n");
00155
00156 int PRNID;
00157 unsigned long temp;
00158 for ( SVDataI p=svdMap.begin(); p!=svdMap.end(); ++p )
00159 {
00160 PRNID = p->first;
00161 SVData& rsvd = p->second;
00162 SVPCodeGen& rsvp = *(rsvd.PCodeGen);
00163 CodeBuffer& rcb = *(rsvd.PCodeBuf);
00164 rsvp.getCurrentSixSeconds( rcb );
00165 temp = rcb[NUM_6SEC_WORDS-1];
00166 fprintf( outFile," %02d x%08X",PRNID,temp);
00167 for (long n=EndOfWeekTestWord;n<EndOfWeekTestEnd;n++)
00168 {
00169 fprintf(outFile," x%08X",rcb[n]);
00170 }
00171 fprintf(outFile,"\n");
00172 }
00173
00174
00175
00176
00177 printf(" Closing files.\n");
00178 fflush( outFile );
00179 fclose( outFile );
00180 return(0);
00181 }