TestIncrementGPS.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 David Chin, Jolien Creighton, Kipp Cannon, Reinhard Prix
00003 *
00004 *  This program is free software; you can redistribute it and/or modify
00005 *  it under the terms of the GNU General Public License as published by
00006 *  the Free Software Foundation; either version 2 of the License, or
00007 *  (at your option) any later version.
00008 *
00009 *  This program is distributed in the hope that it will be useful,
00010 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 *  GNU General Public License for more details.
00013 *
00014 *  You should have received a copy of the GNU General Public License
00015 *  along with with program; see the file COPYING. If not, write to the
00016 *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00017 *  MA  02111-1307  USA
00018 */
00019 
00020 /*
00021  * Author: David Chin <dwchin@umich.edu> +1-734-730-1274
00022  * Revision: $Id: TestIncrementGPS.c,v 1.9 2007/06/08 14:41:43 bema Exp $
00023  */
00024 
00025 #include <stdio.h>
00026 #include <math.h>
00027 #include <stdlib.h>
00028 #include <string.h>
00029 
00030 #include <lal/LALStdlib.h>
00031 #include <lal/Date.h>
00032 #include <lal/AVFactories.h>
00033 
00034 INT4 lalDebugLevel = 0;
00035 
00036 NRCSID (LALTESTINCREMENTGPSC, "$Id: TestIncrementGPS.c,v 1.9 2007/06/08 14:41:43 bema Exp $");
00037 
00038 
00039 #define SUCCESS 0
00040 #define FAILURE 1
00041 
00042 #define TRUE  1
00043 #define FALSE 0
00044 
00045 #define LONGESTSTR 256
00046 
00047 /* Error codes and messages */
00048 
00049 /************** <lalErrTable file="LALTESTINCREMENTGPSCErrorTable"> */
00050 #define LALTESTINCREMENTGPSC_ENORM      0
00051 #define LALTESTINCREMENTGPSC_ESUB       1
00052 
00053 #define LALTESTINCREMENTGPSC_MSGENORM "Normal exit"
00054 #define LALTESTINCREMENTGPSC_MSGESUB  "LAL Subroutine failed"
00055 /******************************************** </lalErrTable> */
00056 
00057 
00058 /*********************************************************************/
00059 /* Macros for printing errors & testing subroutines (from Creighton) */
00060 /*********************************************************************/
00061 
00062 #define ERROR( code, msg, statement )                                \
00063 do {                                                                 \
00064   if ( lalDebugLevel & LALERROR )                                    \
00065     LALPrintError( "Error[0] %d: program %s, file %s, line %d, %s\n" \
00066                    "        %s %s\n", (code), *argv, __FILE__,       \
00067               __LINE__, LALTESTINCREMENTGPSC, statement ? statement :  \
00068                    "", (msg) );                                      \
00069 } while (0)
00070 
00071 #define INFO( statement )                                            \
00072 do {                                                                 \
00073   if ( lalDebugLevel & LALINFO )                                     \
00074     LALPrintError( "Info[0]: program %s, file %s, line %d, %s\n"     \
00075                    "        %s\n", *argv, __FILE__, __LINE__,        \
00076               LALTESTINCREMENTGPSC, (statement) );                     \
00077 } while (0)
00078 
00079 #define SUB( func, statusptr )                                       \
00080 do {                                                                 \
00081   if ( (func), (statusptr)->statusCode ) {                           \
00082     ERROR( LALTESTINCREMENTGPSC_ESUB, LALTESTINCREMENTGPSC_MSGESUB,      \
00083            "Function call \"" #func "\" failed:" );                  \
00084     return LALTESTINCREMENTGPSC_ESUB;                                  \
00085   }                                                                  \
00086 } while (0)
00087 /******************************************************************/
00088 
00089 
00090 
00091 
00092 
00093 /* module-scope variable */
00094 BOOLEAN verbose_p = FALSE;
00095 const INT4 oneBillion = 1000000000;
00096 
00097 
00098 
00099 static int print_compare_errmsg_maybe(const char *msg,
00100                                       LALGPSCompareResult expected_val,
00101                                       LALGPSCompareResult got_val);
00102 
00103 static BOOLEAN compare_gps_ok(LALStatus *status,
00104                               const LIGOTimeGPS *p_gps1,
00105                               const LIGOTimeGPS *p_gps2,
00106                               LALGPSCompareResult expected_val);
00107 
00108 static int sprint_gps_time(char *str, const LIGOTimeGPS *p_gps);
00109 
00110 /* static int sprint_time_interval(char *str,
00111                                 const LALTimeInterval *p_time_interval); */
00112 
00113 static int print_incr_errmsg_maybe(const char *msg,
00114                                    const LIGOTimeGPS *p_expected_gps,
00115                                    const LIGOTimeGPS *p_got_gps);
00116 
00117 static BOOLEAN increment_gps_ok(LALStatus *status,
00118                                 LALTimeInterval *p_delta,
00119                                 LIGOTimeGPS *p_expected_gps,
00120                                 const LIGOTimeGPS *p_got_gps);
00121 
00122 static BOOLEAN decrement_gps_ok(LALStatus *status,
00123                                 LALTimeInterval *p_delta,
00124                                 LIGOTimeGPS *p_expected_gps,
00125                                 const LIGOTimeGPS *p_got_gps);
00126 
00127 
00128 int main(int argc, char **argv)
00129 {
00130   static LALStatus status;
00131   LIGOTimeGPS      gps;
00132   LIGOTimeGPS      another_gps;
00133   LIGOTimeGPS      expected_gps;
00134   LIGOTimeGPS      decremented_gps;
00135   LALTimeInterval  deltaT;
00136   LALTimeInterval  expected_deltaT;
00137 
00138 
00139   if (argc > 1)
00140     lalDebugLevel = atoi(argv[1]);
00141 
00142   if (lalDebugLevel >= 4)
00143     verbose_p = TRUE;
00144 
00145   /*
00146    * TEST No. 0 -- test LALCompareGPS()
00147    */
00148   {
00149     LIGOTimeGPS gps2;
00150 
00151     gps.gpsSeconds      =   1249389;
00152     gps.gpsNanoSeconds  = 498512352;
00153 
00154     /* equal */
00155     gps2.gpsSeconds     =   1249389;
00156     gps2.gpsNanoSeconds = 498512352;
00157 
00158     if (!compare_gps_ok(&status, &gps, &gps2, LALGPS_EQUAL))
00159       return FAILURE;
00160 
00161     /* later */
00162     gps2.gpsNanoSeconds -= 1;
00163     
00164     if (!compare_gps_ok(&status, &gps, &gps2, LALGPS_LATER))
00165       return FAILURE;
00166 
00167     /* earlier */
00168     gps2.gpsNanoSeconds += 2;
00169 
00170     if (!compare_gps_ok(&status, &gps, &gps2, LALGPS_EARLIER))
00171       return FAILURE;
00172 
00173     /* later */
00174     gps2.gpsSeconds -= 1;
00175     gps2.gpsNanoSeconds -= 1;
00176     
00177     if (!compare_gps_ok(&status, &gps, &gps2, LALGPS_LATER))
00178       return FAILURE;
00179 
00180     /* earlier */
00181     gps2.gpsSeconds += 2;
00182 
00183     if (!compare_gps_ok(&status, &gps, &gps2, LALGPS_EARLIER))
00184       return FAILURE;
00185 
00186   } /* END: test of LALCompareGPS() */
00187   
00188 
00189   /*
00190    * TEST No. 1 -- test of LALIncrementGPS()
00191    */
00192   gps.gpsSeconds     =   0;
00193   gps.gpsNanoSeconds =   0;
00194   deltaT.seconds     =  13;
00195   deltaT.nanoSeconds = 100;
00196   expected_gps.gpsSeconds =      13;
00197   expected_gps.gpsNanoSeconds = 100;
00198 
00199   if (!increment_gps_ok(&status, &deltaT, &gps, &expected_gps))
00200     return FAILURE;
00201 
00202   gps.gpsSeconds     = 472139;
00203   gps.gpsNanoSeconds =   1489;
00204   deltaT.seconds     =  10000;
00205   deltaT.nanoSeconds = 700000;
00206   expected_gps.gpsSeconds     = 482139;
00207   expected_gps.gpsNanoSeconds = 701489;
00208 
00209   if (!increment_gps_ok(&status, &deltaT, &gps, &expected_gps))
00210     return FAILURE;
00211 
00212   /*----------------------------------------------------------------------*/
00213   /* test LALAddFloatToGPS() and LALDeltaFloatGPS() */
00214   {
00215     LIGOTimeGPS gps1, gps2, gpsTest, gps3;
00216     REAL8 deltaT1, deltaT0;
00217 
00218     gps1.gpsSeconds = 714153733;
00219     gps1.gpsNanoSeconds = 23421234;
00220 
00221     gps2.gpsSeconds = 715615153;
00222     gps2.gpsNanoSeconds = 712343412;
00223     /* now use DeltaFloatGPS to calculate the difference in seconds */
00224     SUB ( LALDeltaFloatGPS (&status, &deltaT1, &gps1, &gps2), &status);
00225     /* compare to correct result */
00226     deltaT0 = -1461420.688922178;
00227     if (deltaT1 != deltaT0) {
00228       LALPrintError ("Failure in LALDeltaFloatGPS(): got %20.9f instead of %20.9f\n", deltaT1, deltaT0);
00229       return FAILURE;
00230     }
00231     /* now see if deltaT1 takes us from gps1 to gps2 and vice-versa */
00232     SUB (LALAddFloatToGPS (&status, &gpsTest, &gps2, deltaT1), &status);
00233     if ( (gpsTest.gpsSeconds != gps1.gpsSeconds) || (gpsTest.gpsNanoSeconds != gps1.gpsNanoSeconds) ) {
00234       LALPrintError ("Failure in 1.) LALAddFloatToGPS(): got %d.%09ds instead of %d.%09ds\n", 
00235                      gpsTest.gpsSeconds, gpsTest.gpsNanoSeconds, gps1.gpsSeconds, gps1.gpsNanoSeconds);
00236       return FAILURE; 
00237     }
00238     /* no go the other direction..*/
00239     deltaT1 = -deltaT1;
00240     SUB (LALAddFloatToGPS (&status, &gpsTest, &gps1, deltaT1), &status);
00241     if ( (gpsTest.gpsSeconds != gps2.gpsSeconds) || (gpsTest.gpsNanoSeconds != gps2.gpsNanoSeconds) ) {
00242       LALPrintError ("Failure in 2.) LALAddFloatToGPS(): got %d.%09ds instead of %d.%09ds\n", 
00243                      gpsTest.gpsSeconds, gpsTest.gpsNanoSeconds, gps2.gpsSeconds, gps2.gpsNanoSeconds);
00244       return FAILURE;
00245     }
00246     /* test over-run in ns-position is handled properly */
00247     SUB (LALAddFloatToGPS (&status, &gpsTest, &gps2, deltaT1), &status);        /* over-run in positive sense */
00248     gps3.gpsSeconds = 717076574;
00249     gps3.gpsNanoSeconds = 401265590;
00250     if ( (gpsTest.gpsSeconds != gps3.gpsSeconds) || (gpsTest.gpsNanoSeconds != gps3.gpsNanoSeconds) ) {
00251       LALPrintError ("Failure in 3.) LALAddFloatToGPS(): got %d.%09ds instead of %d.%09ds\n", 
00252                      gpsTest.gpsSeconds, gpsTest.gpsNanoSeconds, gps2.gpsSeconds, gps2.gpsNanoSeconds);
00253       return FAILURE;
00254     }
00255     SUB (LALAddFloatToGPS (&status, &gpsTest, &gps1, deltaT1), &status);        /* over-run in negative sense */
00256     gps3.gpsSeconds = 715615153;
00257     gps3.gpsNanoSeconds = 712343412;
00258     if ( (gpsTest.gpsSeconds != gps3.gpsSeconds) || (gpsTest.gpsNanoSeconds != gps3.gpsNanoSeconds) ) {
00259       LALPrintError ("Failure in 4.) LALAddFloatToGPS(): got %d.%09ds instead of %d.%09ds\n", 
00260                      gpsTest.gpsSeconds, gpsTest.gpsNanoSeconds, gps2.gpsSeconds, gps2.gpsNanoSeconds);
00261       return FAILURE;
00262     }
00263 
00264     
00265   } /* testing LALAddFloatToGPS() and LALDeltaFloatGPS() */
00266   /*----------------------------------------------------------------------*/
00267 
00268   /* try passing the same pointer to struct as input and output */
00269   gps.gpsSeconds     =    0;
00270   gps.gpsNanoSeconds =    0;
00271   deltaT.seconds     =   13;
00272   deltaT.nanoSeconds =  100;
00273   expected_gps.gpsSeconds =  13;
00274   expected_gps.gpsNanoSeconds = 100;
00275 
00276 
00277   /* END: test of LALIncrementGPS() */
00278 
00279   /*
00280    * TEST No. 2 -- test of LAlDecrementGPS()
00281    */
00282   gps.gpsSeconds     =     100;
00283   gps.gpsNanoSeconds =      70;
00284   deltaT.seconds     =       1;
00285   deltaT.nanoSeconds =       1;
00286   expected_gps.gpsSeconds =     99;
00287   expected_gps.gpsNanoSeconds = 69;
00288 
00289   if (!decrement_gps_ok(&status, &deltaT, &gps, &expected_gps))
00290     return FAILURE;
00291 
00292   
00293   gps.gpsSeconds     =     100;
00294   gps.gpsNanoSeconds =      70;
00295   deltaT.seconds     =     100;
00296   deltaT.nanoSeconds =      70;
00297   expected_gps.gpsSeconds =     0;
00298   expected_gps.gpsNanoSeconds = 0;
00299 
00300   if (!decrement_gps_ok(&status, &deltaT, &gps, &expected_gps))
00301     return FAILURE;
00302 
00303   gps.gpsSeconds     =    100;
00304   gps.gpsNanoSeconds =     70;
00305   deltaT.seconds     =     90;
00306   deltaT.nanoSeconds =     80;
00307   expected_gps.gpsSeconds     =  9;
00308   expected_gps.gpsNanoSeconds = oneBillion + 70 - 80;
00309 
00310   if (!decrement_gps_ok(&status, &deltaT, &gps, &expected_gps))
00311     return FAILURE;
00312   
00313   /* expect an error on this next one */
00314   gps.gpsSeconds     = 100;
00315   gps.gpsNanoSeconds =  70;
00316   deltaT.seconds     = 100;
00317   deltaT.nanoSeconds =  80;
00318 
00319   LALDecrementGPS(&status, &decremented_gps, &gps, &deltaT);
00320 
00321   if (status.statusCode > 0 && lalDebugLevel > 0)
00322     {
00323       if (status.statusCode == DATEH_EDECRTIMETOOLARGE) /* expected error */
00324         {
00325           fprintf(stderr, "failed with status code %d as expected",
00326                   DATEH_EDECRTIMETOOLARGE);
00327           REPORTSTATUS(&status);
00328         }
00329       else /* some other error */
00330         {
00331           fprintf(stderr, "TestIncrementGPS: LALDecrementGPS() failed, line %i, %s\n",
00332                   __LINE__, LALTESTINCREMENTGPSC);
00333           REPORTSTATUS(&status);
00334           return status.statusCode;
00335         }
00336     }
00337 
00338   /* END: test of LALDecrementGPS() */
00339 
00340 
00341   /*
00342    * TEST 3: test of LALDeltaGPS()
00343    *  (gee, maybe I should have made LIGOTimeGPS and LALTimeInterval
00344    *   into a union)
00345    */
00346   gps.gpsSeconds     = 1234;
00347   gps.gpsNanoSeconds = 4321;
00348   another_gps.gpsSeconds     = 234;
00349   another_gps.gpsNanoSeconds = 321;
00350   expected_deltaT.seconds     = 1000;
00351   expected_deltaT.nanoSeconds = 4000;
00352 
00353   LALDeltaGPS(&status, &deltaT, &gps, &another_gps);
00354 
00355   if (deltaT.seconds != expected_deltaT.seconds ||
00356       deltaT.nanoSeconds != expected_deltaT.nanoSeconds)
00357     {
00358       if (verbose_p)
00359         {
00360           fprintf(stderr, "LALDeltaGPS() failed\n");
00361           fprintf(stderr, "  expected: %9d:%09d\n", expected_deltaT.seconds,
00362                   expected_deltaT.nanoSeconds);
00363           fprintf(stderr, "       got: %9d:%09d\n", deltaT.seconds,
00364                   deltaT.nanoSeconds);
00365         }
00366       
00367       return FAILURE;
00368     }
00369 
00370 
00371   /* just reverse order of inputs */
00372   expected_deltaT.seconds     = -1000;
00373   expected_deltaT.nanoSeconds = -4000;
00374 
00375   LALDeltaGPS(&status, &deltaT, &another_gps, &gps);
00376 
00377   if (deltaT.seconds != expected_deltaT.seconds ||
00378       deltaT.nanoSeconds != expected_deltaT.nanoSeconds)
00379     {
00380       if (verbose_p)
00381         {
00382           fprintf(stderr, "LALDeltaGPS() failed\n");
00383           fprintf(stderr, "  expected %9d:%09d\n", expected_deltaT.seconds,
00384                   expected_deltaT.nanoSeconds);
00385           fprintf(stderr, "       got %9d:%09d\n", deltaT.seconds,
00386                   deltaT.nanoSeconds);
00387         }
00388 
00389       return FAILURE;
00390     }
00391 
00392   /* and a trivial case */
00393   expected_deltaT.seconds     = 0;
00394   expected_deltaT.nanoSeconds = 0;
00395 
00396   LALDeltaGPS(&status, &deltaT, &gps, &gps);
00397 
00398   if (deltaT.seconds != expected_deltaT.seconds ||
00399       deltaT.nanoSeconds != expected_deltaT.nanoSeconds)
00400     {
00401       if (verbose_p)
00402         {
00403           fprintf(stderr, "LALDeltaGPS() failed\n");
00404           fprintf(stderr, "  expected %9d:%09d\n", expected_deltaT.seconds,
00405                   expected_deltaT.nanoSeconds);
00406           fprintf(stderr, "       got %9d:%09d\n", deltaT.seconds,
00407                   deltaT.nanoSeconds);
00408         }
00409 
00410       return FAILURE;
00411     }
00412 
00413   return SUCCESS;
00414 } /* END: main() */
00415 
00416 
00417 
00418 static int print_compare_errmsg_maybe(const char *msg,
00419                                       LALGPSCompareResult expected_val,
00420                                       LALGPSCompareResult got_val)
00421 {
00422   if (verbose_p)
00423     {
00424       char long_msg[LONGESTSTR];
00425       const char *earlier_str = "LALGPS_EARLIER";
00426       const char *equal_str = "LALGPS_EQUAL";
00427       const char *later_str = "LALGPS_LATER";
00428 
00429       if (strlen(msg) > LONGESTSTR - 1)
00430         {
00431           fprintf(stderr, "AARRGGHHH!! string too long\n");
00432           exit(69);
00433         }
00434 
00435       snprintf(long_msg, LONGESTSTR, "%s; expected ", msg);
00436 
00437       switch (expected_val)
00438         {
00439         case LALGPS_EARLIER:
00440           strncat(long_msg, earlier_str, LONGESTSTR - 1 - strlen(long_msg));
00441           break;
00442 
00443         case LALGPS_EQUAL:
00444           strncat(long_msg, equal_str, LONGESTSTR - 1 - strlen(long_msg));
00445           break;
00446 
00447         case LALGPS_LATER:
00448           strncat(long_msg, later_str, LONGESTSTR - 1 - strlen(long_msg));
00449           break;
00450         }
00451 
00452       strncat(long_msg, ", but got ", LONGESTSTR - 1 - strlen(long_msg));
00453 
00454       switch (got_val)
00455         {
00456         case LALGPS_EARLIER:
00457           strncat(long_msg, earlier_str, LONGESTSTR - 1 - strlen(long_msg));
00458           break;
00459 
00460         case LALGPS_EQUAL:
00461           strncat(long_msg, equal_str, LONGESTSTR - 1 - strlen(long_msg));
00462           break;
00463 
00464         case LALGPS_LATER:
00465           strncat(long_msg, later_str, LONGESTSTR - 1 - strlen(long_msg));
00466           break;
00467         }
00468   
00469       return fprintf(stderr, "%s\n\n", long_msg);
00470     }
00471   else
00472     {
00473       return 0;
00474     }
00475 }
00476 
00477 
00478 
00479 static BOOLEAN compare_gps_ok(LALStatus *status,
00480                               const LIGOTimeGPS *p_gps1,
00481                               const LIGOTimeGPS *p_gps2,
00482                               LALGPSCompareResult  expected_val)
00483 {
00484   LALGPSCompareResult rslt;
00485 
00486   LALCompareGPS(status, &rslt, p_gps1, p_gps2);
00487 
00488   if (status->statusCode && lalDebugLevel > 0)
00489       {
00490         fprintf(stderr, "TestIncrementGPS: compare_gps_ok: LALCompareGPS() failed, line %i, %s\n",
00491                 __LINE__, LALTESTINCREMENTGPSC);
00492         REPORTSTATUS(status);
00493         exit (status->statusCode);
00494       }
00495 
00496   if (rslt != expected_val)
00497     {
00498       print_compare_errmsg_maybe("LALCompareGPS() failed",
00499                                  expected_val, rslt);
00500       return FALSE;
00501     }
00502   else
00503     {
00504       return TRUE;
00505     }
00506 }
00507 
00508 
00509 static int sprint_gps_time(char *str, const LIGOTimeGPS *p_gps)
00510 {
00511   return snprintf(str, LONGESTSTR - 1 - strlen(str),
00512                   "%9d:%09d", p_gps->gpsSeconds, p_gps->gpsNanoSeconds);
00513 }
00514 
00515 
00516 #if 0 /* NOT USED */
00517 static int sprint_time_interval(char *str,
00518                                 const LALTimeInterval *p_time_interval)
00519 {
00520   return snprintf(str, LONGESTSTR - 1 - strlen(str),
00521                   "%9d:%09d", p_time_interval->seconds,
00522                   p_time_interval->nanoSeconds);
00523 }
00524 #endif
00525 
00526 
00527 
00528 
00529 static int print_incr_errmsg_maybe(const char *msg,
00530                                    const LIGOTimeGPS *p_expected_gps,
00531                                    const LIGOTimeGPS *p_got_gps)
00532 {
00533   if (verbose_p)
00534     {
00535       char long_msg[LONGESTSTR];
00536 
00537       if (strlen(msg) > LONGESTSTR - 1)
00538         {
00539           fprintf(stderr, "AARRGGHHH!! string too long\n");
00540           exit(69);
00541         }
00542 
00543       snprintf(long_msg, LONGESTSTR, "%s; expected ", msg);
00544       sprint_gps_time(long_msg, p_expected_gps);
00545       snprintf(long_msg, LONGESTSTR, ", got ");
00546       sprint_gps_time(long_msg, p_got_gps);
00547       
00548       return fprintf(stderr, "%s\n\n", long_msg);
00549     }
00550   else
00551     {
00552       return 0;
00553     }
00554 } /* END: print_incr_errmsg_maybe() */
00555                                    
00556 
00557 
00558 static BOOLEAN increment_gps_ok(LALStatus *status,
00559                                 LALTimeInterval *p_delta,
00560                                 LIGOTimeGPS *p_init_gps,
00561                                 const LIGOTimeGPS *p_expected_gps)
00562 {
00563   LALGPSCompareResult cmprslt;
00564 
00565   if (verbose_p)
00566     {
00567       printf("init_gps:     %9d:%09d\n", p_init_gps->gpsSeconds,
00568              p_init_gps->gpsNanoSeconds);
00569       printf("delta_t:      %9d:%09d\n", p_delta->seconds,
00570              p_delta->nanoSeconds);
00571       printf("expected_gps: %9d:%09d\n", p_expected_gps->gpsSeconds,
00572              p_expected_gps->gpsNanoSeconds);
00573     }
00574 
00575   LALIncrementGPS(status, p_init_gps, p_init_gps, p_delta);
00576   LALCompareGPS(status, &cmprslt, p_expected_gps, p_init_gps);
00577 
00578   if (status->statusCode && lalDebugLevel > 0)
00579     {
00580       fprintf(stderr, "TestIncrementGPS: increment_gps_ok: LALIncrementGPS() failed, line %i, %s\n",
00581               __LINE__, LALTESTINCREMENTGPSC);
00582       REPORTSTATUS(status);
00583       exit (status->statusCode);
00584     }  
00585 
00586   if (verbose_p)
00587     {
00588       printf("got_gps:      %9d:%09d\n", p_init_gps->gpsSeconds,
00589              p_init_gps->gpsNanoSeconds);
00590     }
00591   
00592   if (cmprslt != LALGPS_EQUAL)
00593     {
00594       print_incr_errmsg_maybe("LALIncrementGPS() failed",
00595                               p_expected_gps, p_init_gps);
00596       return FALSE;
00597     }
00598   else
00599     {
00600       return TRUE;
00601     }
00602 } /* END: increment_gps_ok() */
00603 
00604 
00605 
00606 static BOOLEAN decrement_gps_ok(LALStatus *status,
00607                                 LALTimeInterval *p_delta,
00608                                 LIGOTimeGPS *p_init_gps,
00609                                 const LIGOTimeGPS *p_expected_gps)
00610 {
00611   LALGPSCompareResult cmprslt;
00612 
00613   if (verbose_p)
00614     {
00615       printf("HELLO THERE\n");
00616       printf("lalDebugLevel = %d\n", lalDebugLevel);
00617       printf("init_gps:     %9d:%09d\n", p_init_gps->gpsSeconds,
00618              p_init_gps->gpsNanoSeconds);
00619       printf("delta_t:      %9d:%09d\n", p_delta->seconds,
00620              p_delta->nanoSeconds);
00621       printf("expected_gps: %9d:%09d\n", p_expected_gps->gpsSeconds,
00622              p_expected_gps->gpsNanoSeconds);
00623     }
00624 
00625   LALDecrementGPS(status, p_init_gps, p_init_gps, p_delta);
00626 
00627   if (verbose_p)
00628     {
00629       printf("got_gps:      %9d:%09d\n", p_init_gps->gpsSeconds,
00630              p_init_gps->gpsNanoSeconds);
00631     }
00632 
00633   /* um, if this fails.... */
00634   LALCompareGPS(status, &cmprslt, p_expected_gps, p_init_gps);
00635 
00636   if (cmprslt != LALGPS_EQUAL)
00637     {
00638       print_incr_errmsg_maybe("LALIncrementGPS() failed",
00639                               p_expected_gps, p_init_gps);
00640       return FALSE;
00641     }
00642   else
00643     {
00644       return TRUE;
00645     }
00646 } /* END: decrement_gps_ok() */

Generated on Mon Oct 6 02:32:19 2008 for LAL by  doxygen 1.5.2