home *** CD-ROM | disk | FTP | other *** search
/ nisttime.carsoncity.k12.mi.us / nisttime.carsoncity.k12.mi.us.tar / nisttime.carsoncity.k12.mi.us / pub / autolock / autolock.h < prev    next >
C/C++ Source or Header  |  2003-12-09  |  4KB  |  105 lines

  1. /*
  2.     this include file defines various constants for the autolock
  3.     program.
  4.  
  5.     NCALMAX is the maximum number of NTP packetes that will
  6.     be sent at any single time.
  7.  
  8.     NUMSRV is the maximum number of servers that can be 
  9.     specified. the actual server addresses are specified in
  10.     the parameter file.  if fewer servers are specified the
  11.     remaining slots are set to 0; if more servers are specified,
  12.     the ones after NUMSRV are ignored.
  13.  
  14.     BINDIR is the directory used to hold all the input and
  15.     output files associated with autolock.
  16.  
  17.     PNAME and SNAME are the names of the parameter file and
  18.     state file, respectively.  The parameter file is only read
  19.     once during a cold-start. The state file is updated after
  20.     each cycle.  It is a last-in first-out stack with the
  21.     most recent data first.
  22. */
  23. #define NCALMAX 50
  24. #define NUMSRV 3    
  25. #define BINDIR "/home/jlevine/autolock"
  26. #define PNAME  "autolock.param"
  27. #define SNAME  "autolock.dat"
  28. /*
  29.     define structure of each autolock record
  30. */
  31. #include "sizint.h"
  32. struct autolockst        /*structure for lock state*/
  33.     {
  34.     LONG  day;        /*MJD of data*/
  35.     LONG  fday;        /*time in milliseconds after midnight*/
  36.     int mode;        /*current mode -- see comments*/
  37.     double x;        /*time difference measured in s*/
  38.     float rms;        /*rms of values that make up x*/
  39.     float rms_avg;        /*12-hour average of rms*/
  40.     int nval;        /*number of values that make up x*/
  41.     double y;        /*rate difference estimated in s/s*/
  42.     double d;        /*drift of local rate in s/s**2  */
  43.     int srv;        /*server number used in this cycle*/
  44.     int flags;        /*state flags -- see comments*/
  45.     int waitn;    /*nominal delay until next time in sec*/
  46.     int waitx;    /*actual delay since last time in sec*/
  47.     double errx;    /*error in time prediction */
  48.     double ybar;    /*average of rate difference y */
  49.     int fcon;    /*time constant for computing ybar*/
  50.     double sumerr;    /*integral of errx with time constant fcon */
  51. } ;
  52. /*
  53.     parameter NUMSTATES sets the size of the push-down stack
  54.     of state vectors that are saved
  55. */
  56. #define NUMSTATES 750
  57. /*
  58.     parameter EVALPERIOD sets the interval after which the
  59.     performance of the algorithm is compared with the desired
  60.     goals and adjustments are made as needed.  The default is
  61.     every day.
  62. */
  63. #define EVALPERIOD 86400
  64. /*
  65.         if parameter KERNEL is 1 then this machine has the modified
  66.         kernel routines originally written by David Mills. the machine 
  67.     uses these kernel routines for leap second control, etc.
  68.         The relevant kernel parameters are defined in timex.h and 
  69.     kern_ntptime.c.  The parameters defined in that documentation are 
  70.     used more or less for their original purposes, except for maxerror
  71.         and esterror, which are used as time-out and crash detectors.
  72.  
  73.         the current version of the kernel software increments maxerr
  74.         by 512 each second.  this version of autolock sets maxerr
  75.         to -512*(sleep time), where sleep time is the time until the
  76.         next calibration/estimation cycle.  maxerr therefore counts back
  77.         towards zero and reaches 0 when the next calibration is due. It
  78.     contines to count upwards after that, and it can therefore be
  79.     used as a time-out indicator -- a positive value indicates that
  80.     something has gone wrong.
  81.     when a calibration cycle is started, the program sets esterror to 
  82.     1 and maxerror to -512*20.  Again, this is used as a time-out flag.
  83.     If maxerror becomes positive in this case with esterror non zero, 
  84.     it means that the program has crashed or gotten stuck in the 
  85.     network access department.
  86.  
  87. */
  88. #define KERNEL 1
  89. /*
  90.       if LINUX is defined, then a number of small changes are made
  91.       to the algorithm. the most important is the use of the 
  92.       semi-kernel routine adjtimex instead of the usual adjtime.
  93. */
  94. /*
  95.       #define LINUX 1
  96. */
  97.  
  98. /*
  99.     it is very important that LINUX and KERNEL not be defined
  100.     at the same time. The two routines using similar structures,
  101.     but the names of the various members are different, and
  102.     lots of errors will be produced if you try to use both
  103.     together.
  104. */
  105.