예제 #1
0
파일: xRinexTest.cpp 프로젝트: PPNav/GPSTk
int main(int argc, char* argv[])
{
      // Set time to Day 153, 2011 (6/2/2011) at noon
   CivilTime g( 2011, 6, 2, 12, 14, 44.0, TimeSystem::GPS );
   CommonTime dt = g.convertToCommonTime();

   short weeknum   = 1638;     // By rules of Kepler Orbit, this must be week of Toe
  
   // Test data from 06/02/2011

   long subframe1[10] = { 0x22C2663D, 0x1F0E29B8, 0x2664002B, 0x09FCC1B6, 0x0F60EB8A,
                          0x1299CE93, 0x29CD3DB6, 0x0597BB0F, 0x00000B68, 0x17B28E5C };
   long subframe2[10] = { 0x22C2663D, 0x1F0E4A28, 0x05809675, 0x0EBD8AF1, 0x00089344,
                          0x008081F8, 0x1330CC2C, 0x0461E855, 0x034F8045, 0x17BB1E68 };
   long subframe3[10] = { 0x22C2663D, 0x1F0E6BA0, 0x3FE129CD, 0x26E31837, 0x0006C96A,
                          0x35A74DFC, 0x065C8B0F, 0x1E4F400A, 0x3FE8966D, 0x05860C44 };
   

   //The dump from ee.dump() and ee_copy.dump() should be the same
   //    an EngEphemeris object is created, then used to create a Rinex3NavData
   EngEphemeris ee;
   ee.addSubframe(subframe1, weeknum, 3, 1);
   ee.addSubframe(subframe2, weeknum, 3, 1);
   ee.addSubframe(subframe3, weeknum, 3, 1);
   ee.dump();

   Rinex3NavData rnd = Rinex3NavData(ee); //constructor

   EngEphemeris ee_copy;
   ee_copy = EngEphemeris(rnd);           //cast
   ee_copy.dump();
}
예제 #2
0
   // Try to convert the given pages into an EngEphemeris object. Returns true
   // upon success.
   bool makeEngEphemeris(EngEphemeris& eph, const EphemerisPages& pages)
   {
      EphemerisPages::const_iterator sf[4];

      sf[1] = pages.find(1);
      if (sf[1] == pages.end())
         return false;
      
      sf[2] = pages.find(2);
      if (sf[2] == pages.end())
         return false;

      sf[3] = pages.find(3);
      if (sf[3] == pages.end())
         return false;

      long t1 = sf[1]->second.getHOWTime();
      long t2 = sf[2]->second.getHOWTime();
      long t3 = sf[3]->second.getHOWTime();
      if (t2 != t1+6 || t3 != t1+12)
         return false;

      int prn = sf[1]->second.prn;
      int week = sf[1]->second.time.GPSfullweek();
      long sfa[10];
      long long_sfa[10];

      for (int i=1; i<=3; i++)
      {
         sf[i]->second.fillArray(sfa);
         for( int j = 0; j < 10; j++ )
            long_sfa[j] = static_cast<long>( sfa[j] );
         if (!eph.addSubframe(long_sfa, week, prn, 0))
            return false;
      }

      if (eph.isData(1) && eph.isData(2) && eph.isData(3))
         return true;

      return false;
   }
void xBrcClockCorrectiongpsNavMsg::firstTest(void)
{
      // Set time to Day 153, 2011 (6/2/2011) at noon
   CivilTime g( 2011, 6, 2, 12, 14, 44.0, TimeSystem::GPS );
   CommonTime dt = g.convertToCommonTime();

      // Test data (copied from navdmp output for .....)
      // Generally, we'd load these data from the file
   std::string SysID = "G";
   ObsID obsID( ObsID::otUndefined, ObsID::cbL1, ObsID::tcCA );
   short PRNID     = 3;
   double Toc      = 388800.0;
   double Top      = 345600.0;
   short weeknum   = 1638;     // By rules of Clock Correction, this must be week of Toc
   short URAoc     = 5;
   short URAoc1    = 7;
   short URAoc2    = 7;
   bool healthy    = true;
   double af0      = 7.23189674E-04;
   double af1      = 5.11590770E-12;
   double af2      = 0.00000000E+00;
   CommonTime TocCT = GPSWeekSecond(weeknum, Toc, TimeSystem::GPS);
   CommonTime TopCT = GPSWeekSecond(weeknum, Top, TimeSystem::GPS);
  
      // Test Data copied from RINEX file	
   double rToc      = 388800.0;
   double rTop      = 345600.0;
   short rweeknum   = 1638;     // By rules of Clock Corection, this must be week of Toc
   short rURAoc     = 5;
   short rURAoc1    = 7;
   short rURAoc2    = 7;
   bool rhealthy    = true;
   double raf0      = 7.23189674318E-04;
   double raf1      = 5.11590769747E-12;
   double raf2      = 0.00000000000E+00;
   CommonTime rTocCT = GPSWeekSecond(rweeknum, rToc, TimeSystem::GPS);
   CommonTime rTopCT = GPSWeekSecond(rweeknum, rTop, TimeSystem::GPS);

   long subframe1[10] = { 0x22C2663D, 0x1F0E29B8, 0x2664002B, 0x09FCC1B6, 0x0F60EB8A,
                          0x1299CE93, 0x29CD3DB6, 0x0597BB0F, 0x00000B68, 0x17B28E5C };
   long subframe2[10] = { 0x22C2663D, 0x1F0E4A28, 0x05809675, 0x0EBD8AF1, 0x00089344,
                          0x008081F8, 0x1330CC2C, 0x0461E855, 0x034F8045, 0x17BB1E68 };
   long subframe3[10] = { 0x22C2663D, 0x1F0E6BA0, 0x3FE129CD, 0x26E31837, 0x0006C96A,
                          0x35A74DFC, 0x065C8B0F, 0x1E4F400A, 0x3FE8966D, 0x05860C44 };

   ofstream outf("Logs/BrcClkCorr_Output", ios::out);

      // First test case. Create an empty CC object, then load the data.
   outf << "Test Case 1: Creating an empty CC object and loading the data." << endl;
   BrcClockCorrection co1;
   co1.loadData( SysID, obsID, PRNID, TocCT, TopCT, URAoc, URAoc1, URAoc2, healthy, 
		           af0, af1, af2 ); 

   double ClkCorr1 = co1.svClockBias( dt );
   outf.precision(11); 
   outf << "Clock Correction co1: " << ClkCorr1 << endl << endl;

      // Second test case. Create an CC object with data available at time of construction.
   outf << "Test Case 2: Creating CC object with data." << endl;
   BrcClockCorrection co2( SysID, obsID, PRNID, TocCT, TopCT, URAoc, URAoc1, URAoc2, healthy, 
		                     af0, af1, af2 ); 

   double ClkCorr2 = co2.svClockBias( dt ); 
   outf << "ClockCorrection co2: " << ClkCorr2 << endl << endl;

      // Third test case. Create a CC object using raw legacy navigation message data
   outf << "Test Case 3: Creating CC object with raw legacy nav message data." << endl;
   BrcClockCorrection co3(obsID, PRNID, weeknum, subframe1 );

   double ClkCorr3 = co3.svClockBias( dt ); 
   outf << "Clock Correction co3: " << ClkCorr3 << endl << endl;

      // Fourth test case. Create a CC object using raw legacy navigation message data
   outf << "Test Case 4: Creating CC object with raw legacy nav message data." << endl;
   BrcClockCorrection co4;
   co4.loadData(obsID, PRNID, weeknum, subframe1 );

   double ClkCorr4 = co4.svClockBias( dt ); 
   outf << "Clock Correction co4: " << ClkCorr4 << endl << endl;

      // Fifth test case. Create an CC object with data available from RINEX file.
   outf << "Test Case 5: Creating CC object with data from RINEX file." << endl;
   BrcClockCorrection co5( SysID, obsID, PRNID, rTocCT, TopCT, URAoc, URAoc1, URAoc2, rhealthy, 
		                     raf0, raf1, raf2 ); 

   double ClkCorr5 = co5.svClockBias( dt ); 
   outf << "Clock Correction co5: " << ClkCorr5 << endl << endl;

      // Sixth test case. Compare against "classic" EngEphemeris
   outf << "Test Case 6: Calculated clock correction using 'classic' EngEphemeris." << endl;
   outf<< "Time= "<< g << endl;
   EngEphemeris EE;
   EE.addSubframe(subframe1, weeknum, 3, 1);
   EE.addSubframe(subframe2, weeknum, 3, 1);
   EE.addSubframe(subframe3, weeknum, 3, 1);

   Xvt xvt = EE.svXvt(dt);
   outf << "Clock Bias EE:  " << xvt.clkbias << endl;
	outf << "Clock Drift EE: " << xvt.clkdrift << endl;
 
      // Test data (copied from navdmp output for PRN 6 Day 155, 2011)
   long subframeA1[10] = { 0x22C2663D, 0x30A2291C, 0x2664002B, 0x0DB9B68A, 0x12746316,
                           0x0BAC1EAA, 0x0DA73D35, 0x1A80002C, 0x00000574, 0x02C3A0F4 };
   long subframeA2[10] = { 0x22C2663D, 0x30A24A8C, 0x1A80864C, 0x0C15B3B1, 0x0AD1AB66,
                           0x00B00201, 0x3A1D9937, 0x00F6A87A, 0x0353C6C1, 0x00001F0C };
   long subframeA3[10] = { 0x22C2663D, 0x30A26B04, 0x3FDF944D, 0x2E5CB356, 0x002FCA3A,
                           0x040A9DDC, 0x0B45D00B, 0x03922318, 0x3FE905EF, 0x1A817FAC };

   CivilTime ct2(2011, 6, 4, 11, 30, 0.0, TimeSystem::GPS );
   dt = ct2.convertToCommonTime( );
   outf << endl << "Test Case 7: Calculated clock corrections using 'classic' EngEphemeris." << endl;
   outf << "Time = " << ct2 << endl;
   EngEphemeris EEA;
   EEA.addSubframe(subframeA1, weeknum, 9, 1);
   EEA.addSubframe(subframeA2, weeknum, 9, 1);
   EEA.addSubframe(subframeA3, weeknum, 9, 1);

   xvt = EEA.svXvt(dt);
   outf << "Clock Bias EE:  "  << xvt.clkbias << endl;
   outf << "Clock Drift EE: " << xvt.clkdrift << endl;

   CivilTime ct3(2011, 6, 5, 1, 0, 0.0, TimeSystem::GPS );
   dt = ct3.convertToCommonTime( );
   outf << endl << "Test Case 8: Calculated clock corrections using 'classic' EngEphemeris." << endl;
   outf << "Time = " << ct3 << endl;

   xvt = EEA.svXvt(dt);
   outf << "Clock Bias EE:  " << xvt.clkbias << endl;
   outf << "Clock Drift EE: " << xvt.clkdrift << endl << endl; 
 
   outf << "Dump Output for Test Cases 4 and 6." << endl;

   outf << "dump EE:" << endl;
   outf << EE << endl;

   outf << "dump co4:" << endl;
   outf << co4 << endl;

   CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/BrcClkCorr_Truth",(char*)"Logs/BrcClkCorr_Output"));
}
예제 #4
0
void xCNAVClockgpsNavMsg::firstTest(void)
{
      // Set time to Day 153, 2011 (6/2/2011) at noon
   CivilTime g( 2011, 6, 2, 12, 14, 44.0, TimeSystem::GPS );
   CommonTime dt = g.convertToCommonTime();

      // Test data (copied from navdmp output for .....)
      // Generally, we'd load these data from the file
   std::string SysID = "G";
   ObsID obsID( ObsID::otNavMsg, ObsID::cbL2, ObsID::tcC2LM );
   ObsID obsID2( ObsID::otNavMsg, ObsID::cbL5, ObsID::tcIQ5 );
   short PRNID     = 3;
   double Toc      = 388800.0;
   short TOWWeek   = 1638;     // By rules of Clock Correction, this must be week of Toc
   double accuracy = 10.61;

      // Test Data copied from RINEX file	
   short rTOWWeek   = 1638;    // By rules of Clock Correction, this must be week of Toc
   double raccuracy = 10.61;
   double rToc      = 388800.0;
   double raf0      = 7.23189674318E-04;
   double raf1      = 5.11590769747E-12;
   double raf2      = 0.0;
   long TOWMsg_1    = 382500;
   long Top         = 378000;
   short AlertMsg   = 0;
   short URAoc_1    = 4;
   short URAoc1_1   = 1;
   short URAoc2_1   = 2;

      // Set time to Day 156, 2011 (6/5/2011) at 1 am
   CivilTime ct2( 2011, 6, 5, 1, 0, 0.0, TimeSystem::GPS );
   CommonTime dt2 = ct2.convertToCommonTime();

      // Test data (copied from navdmp output for PRN 7 Day 156, 2011 at 00:00:00 Transmit Time)
      // Generally, we'd load these data from the file
   short PRNID2     = 7;
   double Toc2      = 7200.0;
   short TOWWeek2   = 1639;     // By rules of Clock Correction, this must be week of Toc
   double accuracy2 = 10.61;
   double af0_2     = 1.32815912E-05;
   double af1_2     = 1.25055521E-12;
   double af2_2     = 0.0;
   long TOWMsg_2    = 0;
   long Top2        = 601200;
   short AlertMsg2  = 1;
   short URAoc_2    = 1;
   short URAoc1_2   = 2;
   short URAoc2_2   = 3;


      // Set time to Day 156, 2011 (6/5/2011) at midnight
   CivilTime ct3( 2011, 6, 5, 0, 0, 0.0, TimeSystem::GPS );
   CommonTime dt3 = ct2.convertToCommonTime();

      // Test data (copied from navdmp output for PRN 9 Day 155, 2011 at 22:00:00 Transmit Time)
      // Generally, we'd load these data from the file
   short PRNID3     = 9;
   double Toc3      = 0.0;
   short TOWWeek3   = 1638;     // By rules of Clock Corection, this must be week of Toc
   double accuracy3 = 10.61;
   long TOWMsg_3    = 597600;
   long Top3        = 594000;
   double af0_3     = 8.43554735E-05;
   double af1_3     = 2.38742359E-12;
   double af2_3     = 0.0;
   short health3    = 0;
   long TOW3        = 597600; 
   short URAoc_3    = 1;
   short URAoc1_3   = 2;
   short URAoc2_3   = 3;

  
   long subframe1[10] = { 0x22C2663D, 0x1F0E29B8, 0x2664002B, 0x09FCC1B6, 0x0F60EB8A,
                          0x1299CE93, 0x29CD3DB6, 0x0597BB0F, 0x00000B68, 0x17B28E5C };
   long subframe2[10] = { 0x22C2663D, 0x1F0E4A28, 0x05809675, 0x0EBD8AF1, 0x00089344,
                         0x008081F8, 0x1330CC2C, 0x0461E855, 0x034F8045, 0x17BB1E68 };
   long subframe3[10] = { 0x22C2663D, 0x1F0E6BA0, 0x3FE129CD, 0x26E31837, 0x0006C96A,
                          0x35A74DFC, 0x065C8B0F, 0x1E4F400A, 0x3FE8966D, 0x05860C44 };

   ofstream outf("Logs/CNAVClock_Output", ios::out);
   outf.precision(11);

      // First test case.  Create an CC object with data available from RINEX file.
   outf << endl << "Test Case 1: Creating CC object with data from RINEX file." << endl;
   outf << "Time = " << g << endl;
   CNAVClock cc1;
   cc1.loadData( SysID, obsID, PRNID, AlertMsg, TOWMsg_1, rTOWWeek, Top,
                 rToc, raccuracy, URAoc_1, URAoc1_1, URAoc2_1, raf0, raf1, raf2 );

   double ClkCorr1 = cc1.svClockBias( dt );
   double ClkDrift1 = cc1.svClockDrift( dt ); 
   outf << "Clock Bias cc1:         " << ClkCorr1 << endl;
   outf << "Clock Drift cc1:        " << ClkDrift1 << endl;
   outf << "Time of Prediction cc1: " << GPSWeekSecond(cc1.getTimeOfPrediction()).printf("%F, %g") << endl;
   outf << "CNAV Accuracy Test:     " << SV_CNAV_ACCURACY_GPS_MAX_INDEX[URAoc_1+15] << endl;
   outf << "legacy Accuracy Test:   " << SV_ACCURACY_GPS_MAX_INDEX[URAoc_1] << endl;

      // Second test case.  Create an CC object with data available from navdump.
   outf << endl << "Test Case 2: Creating CC object with data from navdump." << endl;
   outf << "Time = " << ct2 << endl;
   CNAVClock cc2;
   cc2.loadData( SysID, obsID2, PRNID2, AlertMsg2, TOWMsg_2, TOWWeek2, Top2,
                 Toc2, accuracy2, URAoc_2, URAoc1_2, URAoc2_2, af0_2, af1_2, af2_2 );

   double ClkCorr2 = cc2.svClockBias( dt2 );
   double ClkDrift2 = cc2.svClockDrift( dt2 ); 
   outf << "Clock Bias cc2:  "        << ClkCorr2 << endl;
   outf << "Clock Drift cc2: "        << ClkDrift2 << endl; 
   outf << "Time of Prediction cc2: " << GPSWeekSecond(cc2.getTimeOfPrediction()).printf("%F, %g") << endl;

      // Third test case.  Create an CC object with data available from navdump.
   outf << endl << "Test Case 3: Creating CC object with data from navdump." << endl;
   outf << "Time = " << ct3 << endl;
   CNAVClock cc3;
   cc3.loadData( SysID, obsID, PRNID3, AlertMsg, TOWMsg_3, TOWWeek3, Top3,
                 Toc3, accuracy3, URAoc_3, URAoc1_3, URAoc2_3, af0_3, af1_3, af2_3 );

   double ClkCorr3 = cc3.svClockBias( dt3 );
   double ClkDrift3 = cc3.svClockDrift( dt3 ); 
   outf << "Clock Bias cc3:  "        << ClkCorr3 << endl;
   outf << "Clock Drift cc3: "        << ClkDrift3 << endl; 
   outf << "Time of Prediction cc3: " << GPSWeekSecond(cc3.getTimeOfPrediction()).printf("%F, %g") << endl;

      // Fourth test case.  Compare against "classic" EngEphemeris
   outf << endl << "Test Case 4: Calculated position using 'classic' EngEphemeris." << endl;
   outf<< "Time= "<< g << endl;
   EngEphemeris EE;
   EE.addSubframe(subframe1, TOWWeek, 3, 1);
   EE.addSubframe(subframe2, TOWWeek, 3, 1);
   EE.addSubframe(subframe3, TOWWeek, 3, 1);

   Xvt xvt = EE.svXvt(dt);
   outf<< "Clock Bias EE:  " << xvt.clkbias << endl;
   outf<< "Clocl Drift EE: " << xvt.clkdrift << endl;

   outf << endl;
   outf << "CC1 Object Dump:" << endl;
   outf << cc1 << endl;

   outf << endl;
   outf << "CC2 Object Dump:" << endl;
   outf << cc2 << endl;

   outf << endl;
   outf << "CC3 Object Dump:" << endl;
   outf << cc3 << endl;

   CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/CNAVClock_Truth",(char*)"Logs/CNAVClock_Output"));
}
예제 #5
0
void xCNAVEphemerisgpsNavMsg::firstTest(void)
{
      // Set time to Day 153, 2011 (6/2/2011) at noon
   CivilTime g( 2011, 6, 2, 12, 14, 44.0, TimeSystem::GPS );
   CommonTime dt = g.convertToCommonTime();

      // Test data (copied from navdmp output for .....)
      // Generally, we'd load these data from the file
   std::string SysID = "G";
   ObsID obsID( ObsID::otNavMsg, ObsID::cbL2, ObsID::tcC2LM );
   ObsID obsID2( ObsID::otNavMsg, ObsID::cbL5, ObsID::tcIQ5 );
   short PRNID     = 3;
   double Toe      = 388800.0;
   short TOWWeek   = 1638;     // By rules of Kepler Orbit, this must be week of Toe
   double accuracy = 10.61;
   double Cuc      = 9.57399607E-07;
   double Cus      = 8.35768878E-06;
   double Crc      = 2.03562500E+02;
   double Crs      = 1.87812500E+01;
   double Cic      = -2.30967999E-07;
   double Cis      = 5.02914190E-08;
   double M0       = 1.05539163E+00;
   double dn       = 5.39093884E-09;
   double dnDot    = 0.0;                // Doesn't exist in legacy navigation message
   double ecc      = 1.42575260E-02;
   double Ahalf    = 5.15365528E+03; 
   double A        = Ahalf * Ahalf;      // Changed from legacy navigation message
   double Adot     = 0.0;                // Doesn't exist in legacy navigation message  
   double OMEGA0   = -2.16947563E+00;
   double i0       = 9.28692498E-01;
   double w        = 1.09154605E+00;
   double OMEGAdot = -8.56285668E-09;
   double idot     = 5.52880173E-10;

      // Test Data copied from RINEX file	
   double rToe      = 388800.0;
   short rTOWWeek   = 1638;     // By rules of Kepler Orbit, this must be week of Toe
   double raccuracy = 10.61;
   double rToc      = 388800.0;
   short rTracker   = 1;
   double rCuc      = 9.57399606705E-07;
   double rCus      = 8.35768878460E-06;
   double rCrc      = 2.03562500000E+02;
   double rCrs      = 1.87812500000E+01;
   double rCic      = -2.30967998505E-07;
   double rCis      = 5.02914190292E-08;
   double rM0       = 1.05539162795E+00;
   double rdn       = 5.39093883996E-09;
   double rdnDot    = 0.0;                // Doesn't exist in legacy navigation message
   double recc      = 1.42575260252E-02;
   double rAhalf    = 5.15365527534E+03; 
   double rA        = rAhalf * rAhalf;    // Changed from legacy navigation message
   double rAdot     = 0.0;                // Doesn't exist in legacy navigation message  
   double rOMEGA0   = -2.16947563164E+00;
   double ri0       = 9.28692497530E-01;
   double rw        = 1.09154604931E+00;
   double rOMEGAdot = -8.56285667735E-09;
   double deltaOMEGAdot1 = rOMEGAdot - OMEGADOT_REF_GPS;
   double ridot     = 5.52880172536E-10;

   double deltaA    = rA - A_REF_GPS;
   long TOWMsg10_1  = 382500;
   long TOWMsg11_1  = 382500; 
   long Top         = 378000;
   short URAoe      = 1;
   short AlertMsg10 = 0;
   short AlertMsg11 = 0;
   short L1Health   = 0;
   short L2Health   = 0;
   short L5Health   = 1;

      // Set time to Day 156, 2011 (6/5/2011) at 1 am
   CivilTime ct2( 2011, 6, 5, 1, 0, 0.0, TimeSystem::GPS );
   CommonTime dt2 = ct2.convertToCommonTime();

      // Test data (copied from navdmp output for PRN 7 Day 156, 2011 at 00:00:00 Transmit Time)
      // Generally, we'd load these data from the file
   short PRNID2     = 7;
   double Toe2      = 7200.0;
   short TOWWeek2   = 1639;     // By rules of Kepler Orbit, this must be week of Toe
   double accuracy2 = 10.61;
   double Cuc2      = 6.33299351E-08;
   double Cus2      = 9.79751348E-07;
   double Crc2      = 3.67843750E+02;
   double Crs2      = 3.75000000E+01;
   double Cic2      = 1.13621354E-07;
   double Cis2      = 2.79396772E-08;
   double M02       = 5.40667729E-01;
   double dn2       = 4.46804325E-09;
   double dnDot2    = 0.0;                // Doesn't exist in legacy navigation message
   double ecc2      = 4.48677479E-03;
   double Ahalf2    = 5.15365555E+03; 
   double A2        = Ahalf2 * Ahalf2;    // Changed from legacy navigation message
   double Adot2     = 0.0;                // Doesn't exist in legacy navigation message  
   double OMEGA02   = 2.03414883+00;
   double i02       = 9.74404003E-01;
   double w2        = -3.13294415E+00;
   double OMEGAdot2 = -8.35713382E-09;
   double deltaOMEGAdot2 = OMEGAdot2 - OMEGADOT_REF_GPS;
   double idot2     = 1.21433630E-10;
   double Tgd2      = -1.07102096E-08;
   double deltaA2   = A2 - A_REF_GPS;
   long TOWMsg10_2  = 0;
   long TOWMsg11_2  = 0; 
   long Top2        = 601200;
   short URAoe2     = 1;


      // Set time to Day 156, 2011 (6/5/2011) at midnight
   CivilTime ct3( 2011, 6, 5, 0, 0, 0.0, TimeSystem::GPS );
   CommonTime dt3 = ct2.convertToCommonTime();

      // Test data (copied from navdmp output for PRN 9 Day 155, 2011 at 22:00:00 Transmit Time)
      // Generally, we'd load these data from the file
   short PRNID3     = 9;
   double Toe3      = 0.0;
   short TOWWeek3   = 1638;     // By rules of Kepler Orbit, this must be week of Toe
   double accuracy3 = 10.61;
   double Cuc3      = 1.31130219E-06;
   double Cus3      = 1.83656812E-06;
   double Crc3      = 3.60718750E+02;
   double Crs3      = 1.67812500E+01;
   double Cic3      = -2.42143869E-07;
   double Cis3      = 3.55765224E-07;
   double M03       = -1.22303559E+00;
   double dn3       = 4.41946980E-09;
   double dnDot3    = 0.0;                // Doesn't exist in legacy navigation message
   double ecc3      = 1.73985478E-02;
   double Ahalf3    = 5.15366363E+03; 
   double A3        = Ahalf3 * Ahalf3;    // Changed from legacy navigation message
   double Adot3     = 0.0;                // Doesn't exist in legacy navigation message  
   double OMEGA03   = 2.00581875E+00;
   double i03       = 9.83297588E-01;
   double w3        = 1.57216573E+00;
   double OMEGAdot3 = -8.40356433E-09;
   double deltaOMEGAdot3 = OMEGAdot3 - OMEGADOT_REF_GPS;
   double idot3     = 1.36791412E-10;
   double Tgd3      = -5.58793545E-09;
    double deltaA3  = A3 - A_REF_GPS;
   long TOWMsg10_3  = 597600;
   long TOWMsg11_3  = 597600; 
   long Top3        = 594000;
   short URAoe3     = 1;

  
   long subframe1[10] = { 0x22C2663D, 0x1F0E29B8, 0x2664002B, 0x09FCC1B6, 0x0F60EB8A,
                          0x1299CE93, 0x29CD3DB6, 0x0597BB0F, 0x00000B68, 0x17B28E5C };
   long subframe2[10] = { 0x22C2663D, 0x1F0E4A28, 0x05809675, 0x0EBD8AF1, 0x00089344,
                         0x008081F8, 0x1330CC2C, 0x0461E855, 0x034F8045, 0x17BB1E68 };
   long subframe3[10] = { 0x22C2663D, 0x1F0E6BA0, 0x3FE129CD, 0x26E31837, 0x0006C96A,
                          0x35A74DFC, 0x065C8B0F, 0x1E4F400A, 0x3FE8966D, 0x05860C44 };

   ofstream outf("Logs/CNAVEphemeris_Output", ios::out);
   outf.precision(11);

      // First test case.  Create an CE object with data available from RINEX file.
   outf << endl << "Test Case 1: Creating CE object with data from RINEX file." << endl;
   outf << "Time = " << g << endl;
   CNAVEphemeris ce1;
   ce1.loadData(SysID, obsID, PRNID, AlertMsg10, TOWMsg10_1, AlertMsg11,
                TOWMsg11_1, rTOWWeek, Top, URAoe, L1Health, L2Health, 
		          L5Health, rToe, raccuracy, rCuc, rCus, rCrc, rCrs, rCic,
                rCis, rM0, rdn, rdnDot, recc, deltaA, rAdot, rOMEGA0, 
                ri0, rw, deltaOMEGAdot1, ridot );

   Xv  xv1 = ce1.svXv( dt ); 
   outf << "Position ce1: "           << xv1.x << endl;
   outf << "Velocity ce1: "           << xv1.v << endl;
   outf << "RelCorr ce1:  "           << ce1.svRelativity(dt) << endl;
   outf << "Time of Prediction ce1: " << GPSWeekSecond(ce1.getTimeOfPrediction()).printf("%F, %g") << endl;
   outf << "CNAV Accuracy Test:  "    << SV_CNAV_ACCURACY_GPS_MAX_INDEX[URAoe+15] << endl;
   outf << "legacy Accuracy Test: "   << SV_ACCURACY_GPS_MAX_INDEX[URAoe] << endl;

      // Second test case.  Create an CE object with data available from navdump.
   outf << endl << "Test Case 2: Creating CE object with data from navdump." << endl;
   outf << "Time = " << ct2 << endl;
   CNAVEphemeris ce2;
   ce2.loadData( SysID, obsID2, PRNID2, AlertMsg10, TOWMsg10_2, AlertMsg11,
                TOWMsg11_2, TOWWeek2, Top2, URAoe2, L1Health, L2Health, 
		          L5Health, Toe2, accuracy2, Cuc2, Cus2, Crc2, Crs2, Cic2,
                Cis2, M02, dn2, dnDot2, ecc2, deltaA2, Adot2, OMEGA02, 
                i02, w2, deltaOMEGAdot2, idot2 );

   Xv  xv2 = ce2.svXv( dt2 ); 
   outf << "Position ce2: "           << xv2.x << endl;
   outf << "Velocity ce2: "           << xv2.v << endl;
   outf << "RelCorr ce2:  "           << ce2.svRelativity(dt2) << endl;
   outf << "Time of Prediction ce2: " << GPSWeekSecond(ce2.getTimeOfPrediction()).printf("%F, %g") << endl;

      // Third test case.  Create an CE object with data available from navdump.
   outf << endl << "Test Case 3: Creating CE object with data from navdump." << endl;
   outf << "Time = " << ct3 << endl;
   CNAVEphemeris ce3;
   ce3.loadData( SysID, obsID, PRNID3, AlertMsg10, TOWMsg10_3, AlertMsg11,
                TOWMsg11_3, TOWWeek3, Top3, URAoe3, L1Health, L2Health, 
		          L5Health, Toe3, accuracy3, Cuc3, Cus3, Crc3, Crs3, Cic3,
                Cis3, M03, dn3, dnDot3, ecc3, deltaA3, Adot3, OMEGA03, 
                i03, w3, deltaOMEGAdot3, idot3 );

   Xv  xv3 = ce3.svXv( dt3 ); 
   outf << "Position ce3: "           << xv3.x << endl;
   outf << "Velocity ce3: "           << xv3.v << endl;
   outf << "RelCorr ce3:  "           << ce3.svRelativity(dt3) << endl;
   outf << "Time of Prediction ce3: " << GPSWeekSecond(ce3.getTimeOfPrediction()).printf("%F, %g") << endl;

      // Fourth test case.  Compare against "classic" EngEphemeris
   outf << endl << "Test Case 4: Calculated position using 'classic' EngEphemeris." << endl;
   outf<< "Time= "<< g << endl;
   EngEphemeris EE;
   EE.addSubframe(subframe1, TOWWeek, 3, 1);
   EE.addSubframe(subframe2, TOWWeek, 3, 1);
   EE.addSubframe(subframe3, TOWWeek, 3, 1);

   Xvt xvt = EE.svXvt(dt);
   outf<< "Position EE: " << xvt.x << endl;
   outf<< "Velocity EE: " << xvt.v << endl;
   outf<< "RelCorr EE:  " << EE.svRelativity(dt) << endl;

   outf << endl;
   outf << "CE Object Dump:" << endl;
   outf << ce1 << endl;
   if ( ce1.getOrbit().isHealthy()) outf << "CE.orbit is healthy." << endl;
   else outf << "CE.orbit is NOT healthy." << endl;

   outf << endl;
   outf << "CE2 Object Dump:" << endl;
   outf << ce2 << endl;
   if ( ce2.getOrbit().isHealthy()) outf << "CE2.orbit is healthy." << endl;
   else outf << "CE2.orbit is NOT healthy." << endl;

   outf << endl;
   outf << "CE3 Object Dump:" << endl;
   outf << ce3 << endl;
   if ( ce3.getOrbit().isHealthy()) outf << "CE3.orbit is healthy." << endl;
   else outf << "CE3.orbit is NOT healthy." << endl;

   outf << endl;
   outf << "Fit Interval Tests" << endl;
   outf << "BeginFit ce1:  "    << GPSWeekSecond(ce1.getOrbit().getBeginningOfFitInterval()).printf("%F, %g") << endl;
   outf << "BeginFit EE:   "    << GPSWeekSecond(EE.getOrbit().getBeginningOfFitInterval()).printf("%F, %g") << endl;

   outf << endl;
   outf << "EndFit ce1:   " << GPSWeekSecond(ce1.getOrbit().getEndOfFitInterval()).printf("%F, %g") << endl;
   outf << "EndFit EE  :  " << GPSWeekSecond(EE.getOrbit().getEndOfFitInterval()).printf("%F, %g") << endl;

   outf << endl;
   outf << "Within Fit Interval: " << ce1.getOrbit().withinFitInterval(dt) << endl;
   outf << "Within Fit Interval: " << EE.getOrbit().withinFitInterval(dt) << endl;

   CPPUNIT_ASSERT(fileEqualTest((char*)"Logs/CNAVEphemeris_Truth",(char*)"Logs/CNAVEphemeris_Output"));
}