Exemplo n.º 1
0
      // initializationTest ensures the constructors set the values properly
   unsigned initializationTest()
   {
      TUDEF("GPSWeekSecond", "Constructor");

      GPSWeekSecond compare(1300,13500.,TimeSystem(2)); //Initialize an object
         //--------------------------------------------------------------------
         //Were the attributes set to expectation with the explicit
         //constructor?
         //--------------------------------------------------------------------
      TUASSERTE(int, 1300, compare.week);
      TUASSERTFE(13500, compare.sow);
      TUASSERTE(TimeSystem, TimeSystem(2), compare.getTimeSystem());


      testFramework.changeSourceMethod("ConstructorCopy");
      GPSWeekSecond copy(compare); // Initialize with copy constructor
         //--------------------------------------------------------------------
         //Were the attributes set to expectation with the copy constructor?
         //--------------------------------------------------------------------
      TUASSERTE(int, 1300, copy.week);
      TUASSERTFE(13500, copy.sow);
      TUASSERTE(TimeSystem, TimeSystem(2), copy.getTimeSystem());

      testFramework.changeSourceMethod("operator=");
      GPSWeekSecond assigned;
      assigned = compare;
         //--------------------------------------------------------------------
         //Were the attributes set to expectation with the Set operator?
         //--------------------------------------------------------------------
      TUASSERTE(int, 1300, assigned.week);
      TUASSERTFE(13500, assigned.sow);
      TUASSERTE(TimeSystem, TimeSystem(2), assigned.getTimeSystem());

      TURETURN();
   }
Exemplo n.º 2
0
static void timeDisplay( ostream & os, const CommonTime& t )
{
    // Convert to CommonTime struct from GPS wk,SOW to M/D/Y, H:M:S.
    GPSWeekSecond dummyTime;
    dummyTime = GPSWeekSecond(t);
    os << dec;
    os << setw(4) << dummyTime.week << "(";
    os << setw(4) << (dummyTime.week & 0x03FF) << ")  ";
    os << setw(6) << setfill(' ') << dummyTime.sow << "   ";

    switch (dummyTime.getDayOfWeek())
    {
    case 0:
        os << "Sun-0";
        break;
    case 1:
        os << "Mon-1";
        break;
    case 2:
        os << "Tue-2";
        break;
    case 3:
        os << "Wed-3";
        break;
    case 4:
        os << "Thu-4";
        break;
    case 5:
        os << "Fri-5";
        break;
    case 6:
        os << "Sat-6";
        break;
    default:
        break;
    }
    os << "   " << (static_cast<YDSTime>(t)).printf("%3j   %5.0s  ")
       << (static_cast<CivilTime>(t)).printf("%02m/%02d/%04Y   %02H:%02M:%02S");
}
Exemplo n.º 3
0
   void CNavDataElement::timeDisplay( ostream & os, const CommonTime& t )
   {
      os.setf(ios::dec, ios::basefield);
         // Convert to CommonTime struct from GPS wk,SOW to M/D/Y, H:M:S.
      GPSWeekSecond dummyTime;
      dummyTime = GPSWeekSecond(t);
      os << setw(4) << dummyTime.week << "(";
      os << setw(4) << (dummyTime.week & 0x03FF) << ")  ";
      os << setw(6) << setfill(' ') << dummyTime.sow << "   ";

      switch (dummyTime.getDayOfWeek())
      {
         case 0: os << "Sun-0"; break;
         case 1: os << "Mon-1"; break;
         case 2: os << "Tue-2"; break;
         case 3: os << "Wed-3"; break;
         case 4: os << "Thu-4"; break;
         case 5: os << "Fri-5"; break;
         case 6: os << "Sat-6"; break;
         default: break;
      }
      os << printTime(t,"   %3j   %5.0s   %02m/%02d/%04Y   %02H:%02M:%02S");
   }
Exemplo n.º 4
0
//=============================================================================
//	initializationTest ensures the constructors set the values properly
//=============================================================================
   int initializationTest(void)
   {
      TestUtil testFramework( "GPSWeekSecond", "Constructor", __FILE__, __LINE__ );

      GPSWeekSecond Compare(1300,13500.,TimeSystem(2)); //Initialize an object
         //--------------------------------------------------------------------
         //Were the attributes set to expectation with the explicit
         //constructor?
         //--------------------------------------------------------------------
      testFramework.assert(1300 == Compare.week,                     "Explicit constructor did not set the week value properly", __LINE__);
      testFramework.assert(fabs((double)13500 - Compare.sow) < eps,  "Explicit constructor did not set the sow value properly",  __LINE__);
      testFramework.assert(TimeSystem(2) == Compare.getTimeSystem(), "Explicit constructor did not set the TimeSystem properly", __LINE__);


      testFramework.changeSourceMethod("ConstructorCopy");
      GPSWeekSecond Copy(Compare); // Initialize with copy constructor
         //--------------------------------------------------------------------
         //Were the attributes set to expectation with the copy constructor?
         //--------------------------------------------------------------------
      testFramework.assert(1300 == Copy.week,                     "Copy constructor did not set the week value properly", __LINE__);
      testFramework.assert(fabs((double)13500 - Copy.sow) < eps,  "Copy constructor did not set the sow value properly",  __LINE__);
      testFramework.assert(TimeSystem(2) == Copy.getTimeSystem(), "Copy constructor did not set the TimeSystem properly", __LINE__);


      testFramework.changeSourceMethod("OperatorSet");
      GPSWeekSecond Assigned;
      Assigned = Compare;
         //--------------------------------------------------------------------
         //Were the attributes set to expectation with the Set operator?
         //--------------------------------------------------------------------
      testFramework.assert(1300 == Assigned.week,                     "Set Operator did not set the week value properly", __LINE__);
      testFramework.assert(fabs((double)13500 - Assigned.sow) < eps,  "Set Operator did not set the sow value properly",  __LINE__);
      testFramework.assert(TimeSystem(2) == Assigned.getTimeSystem(), "Set Operator did not set the TimeSystem properly", __LINE__);

      return testFramework.countFails();
   }
Exemplo n.º 5
0
   double TimeSystemCorrection ::
   Correction(const CommonTime& ct) const
   {
      double corr(0.0), dt;
      TimeSystem fromTS(ct.getTimeSystem());
      GPSWeekSecond gpsws;
      CommonTime refTime;
      Exception e("Unable to compute correction - wrong TimeSystem");
      Exception eSBAS("TimeSystemCorrection SBAS <=> UTC has not been implemented");

      switch(type)
      {
         case GPUT:
            if(fromTS != TimeSystem::GPS && fromTS != TimeSystem::UTC)
            {
               GPSTK_THROW(e);
            }

               // dt = fromTime - refTime
            gpsws = GPSWeekSecond(refWeek,refSOW);
            refTime = gpsws.convertToCommonTime();
            refTime.setTimeSystem(fromTS);
            dt = ct - refTime;

            if(fromTS == TimeSystem::GPS)             // GPS => UTC
               corr = -A0-A1*dt;
            else                                      // UTC => GPS
               corr = A0+A1*dt;

            break;

         case GAUT:
            if(fromTS != TimeSystem::GAL && fromTS != TimeSystem::UTC)
            { GPSTK_THROW(e); }

               // dt = fromTime - refTime
            gpsws = GPSWeekSecond(refWeek,refSOW);
            refTime = gpsws.convertToCommonTime();
            refTime.setTimeSystem(fromTS);
            dt = ct - refTime;

            if(fromTS == TimeSystem::GAL)             // GAL => UTC
               corr = A0+A1*dt;
            else                                      // UTC => GAL
               corr = -A0-A1*dt;

            break;

         case SBUT:
            GPSTK_THROW(eSBAS);
            break;

         case GLUT:
            if(fromTS != TimeSystem::GLO && fromTS != TimeSystem::UTC)
            {
               GPSTK_THROW(e);
            }

            if(fromTS == TimeSystem::GLO)             // GLO => UTC
               corr = A0;
            else                                      // UTC => GLO
               corr = -A0;

            break;

         case GPGA:
            if(fromTS != TimeSystem::GPS && fromTS != TimeSystem::GAL)
            {
               GPSTK_THROW(e);
            }

               // dt = fromTime - refTime
            gpsws = GPSWeekSecond(refWeek,refSOW);
            refTime = gpsws.convertToCommonTime();
            refTime.setTimeSystem(fromTS);
            dt = ct - refTime;

            if(fromTS == TimeSystem::GPS)             // GPS => GAL
               corr = A0+A1*dt;
            else                                      // GAL => GPS
               corr = -A0-A1*dt;

            break;

         case GLGP:
            if(fromTS != TimeSystem::GLO && fromTS != TimeSystem::GPS)
            {
               GPSTK_THROW(e);
            }

            if(fromTS == TimeSystem::GLO)             // GLO => GPS
               corr = A0;
            else                                      // GPS => GLO
               corr = -A0;

            break;

         case QZGP:
            if(fromTS != TimeSystem::QZS && fromTS != TimeSystem::GPS)
            {
               GPSTK_THROW(e);
            }

            if(fromTS == TimeSystem::QZS)             // QZS => GPS
               corr = 0.0;    // TD?
            else                                      // GPS => QZS
               corr = 0.0;    // TD?

            break;

         case QZUT:
            if(fromTS != TimeSystem::QZS && fromTS != TimeSystem::UTC)
            {
               GPSTK_THROW(e);
            }

               // dt = fromTime - refTime
            gpsws = GPSWeekSecond(refWeek,refSOW);
            refTime = gpsws.convertToCommonTime();
            refTime.setTimeSystem(fromTS);
            dt = ct - refTime;

            if(fromTS == TimeSystem::QZS)             // QZS => UTC
               corr = A0+A1*dt;
            else                                      // UTC => QZS
               corr = -A0-A1*dt;

            break;

         case BDUT:
            if(fromTS != TimeSystem::BDT && fromTS != TimeSystem::UTC)
            {
               GPSTK_THROW(e);
            }

               // dt = fromTime - refTime
            gpsws = GPSWeekSecond(refWeek,refSOW);
            refTime = gpsws.convertToCommonTime();
            refTime.setTimeSystem(fromTS);
            dt = ct - refTime;

            if(fromTS == TimeSystem::BDT)             // BDT => UTC
               corr = A0+A1*dt;
            else                                      // UTC => BDT
               corr = -A0-A1*dt;

            break;

         case BDGP:
            if(fromTS != TimeSystem::BDT && fromTS != TimeSystem::GPS)
            {
               GPSTK_THROW(e);
            }

               // dt = fromTime - refTime
            gpsws = GPSWeekSecond(refWeek,refSOW);
            refTime = gpsws.convertToCommonTime();
            refTime.setTimeSystem(fromTS);
            dt = ct - refTime;

            if(fromTS == TimeSystem::BDT)             // BDT => GPS
               corr = A0;
            else                                      // GPS => BDT
               corr = -A0;

            break;

         default:
            Exception e("TimeSystemCorrection is not defined.");
            GPSTK_THROW(e);
            break;
      }

      return corr;
   }