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 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include <map>
00035
00036
00037 #include "PCodeConst.hpp"
00038 #include "SVPCodeGen.hpp"
00039 #include "CodeBuffer.hpp"
00040 #include "X1Sequence.hpp"
00041 #include "X2Sequence.hpp"
00042
00047 using namespace std;
00048 using namespace gpstk;
00049
00050
00051
00052
00053 struct SVData
00054 {
00055 SVPCodeGen * PCodeGen;
00056 CodeBuffer * PCodeBuf;
00057 codeType cType;
00058 SVData( SVPCodeGen * a1,
00059 CodeBuffer * a2,
00060 codeType c )
00061 {
00062 PCodeGen = a1;
00063 PCodeBuf = a2;
00064 cType = c;
00065 };
00066 };
00067
00068 const int NUM_SATS = 38;
00069
00070 int main(int argc, char* argv[])
00071 {
00072 printf("Ryan's Xbegweek\n");
00073
00074 if (argc < 2)
00075 {
00076 printf("Usage: >Xbegweek <outputfile>\n");
00077 exit(1);
00078 }
00079
00080 printf(" Opening output file.\n");
00081 FILE *outFile = fopen( argv[1], "wt" );
00082 if (outFile==NULL)
00083 {
00084 printf(" Cannot open xbegweek.out for output.\n");
00085 exit(-1);
00086 }
00087 fprintf(outFile," Xbegweek.out - Demonstrating P-Code Beginnging of Week Generation..\n");
00088 fprintf(outFile," Reproducing ICD-GPS-200, Table 3-I\n");
00089
00090
00091 printf(" Setting time to beginning of week.\n");
00092
00093 DayTime dt( 1233, 0.0 );
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 try
00105 {
00106 X1Sequence::allocateMemory();
00107 X2Sequence::allocateMemory();
00108 }
00109 catch (gpstk::Exception e)
00110 {
00111 printf(" Memory allocation failure.\n");
00112 printf(" Xbegweek will terminate.\n");
00113 return(1);
00114 }
00115
00116
00117 printf(" Instantiating the PRN arrays.\n");
00118 map<int, SVData>svdMap;
00119 typedef map<int, SVData>::iterator SVDataI;
00120
00121 SVPCodeGen * svp[NUM_SATS];
00122 CodeBuffer * pcb[NUM_SATS];
00123 for (int n=0;n<NUM_SATS;++n)
00124 {
00125 svp[n] = 0;
00126 pcb[n] = 0;
00127 }
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 SVData svd ( svp[PRNndx], pcb[PRNndx], P_CODE );
00134 pair<int,SVData> ps( PRNndx, svd );
00135 svdMap.insert( ps );
00136 }
00137
00138 fprintf(outFile," PRN 12-bits of code (octal)\n");
00139
00140 int PRNID;
00141 unsigned long temp;
00142 for ( SVDataI p=svdMap.begin(); p!=svdMap.end(); ++p)
00143 {
00144 PRNID = p->first;
00145 SVData& rsvd = p->second;
00146 SVPCodeGen& rsvp = *(rsvd.PCodeGen);
00147 CodeBuffer& rcb = *(rsvd.PCodeBuf);
00148 rsvp.getCurrentSixSeconds( rcb );
00149 temp = rcb[0] >> 20;
00150 fprintf( outFile," %02d %04o\n",PRNID,temp);
00151 }
00152
00153
00154 printf(" Closing files.\n");
00155 fflush( outFile );
00156 fclose( outFile );
00157 return(0);
00158 }