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 >
Wrap
C/C++ Source or Header
|
2003-12-09
|
4KB
|
105 lines
/*
this include file defines various constants for the autolock
program.
NCALMAX is the maximum number of NTP packetes that will
be sent at any single time.
NUMSRV is the maximum number of servers that can be
specified. the actual server addresses are specified in
the parameter file. if fewer servers are specified the
remaining slots are set to 0; if more servers are specified,
the ones after NUMSRV are ignored.
BINDIR is the directory used to hold all the input and
output files associated with autolock.
PNAME and SNAME are the names of the parameter file and
state file, respectively. The parameter file is only read
once during a cold-start. The state file is updated after
each cycle. It is a last-in first-out stack with the
most recent data first.
*/
#define NCALMAX 50
#define NUMSRV 3
#define BINDIR "/home/jlevine/autolock"
#define PNAME "autolock.param"
#define SNAME "autolock.dat"
/*
define structure of each autolock record
*/
#include "sizint.h"
struct autolockst /*structure for lock state*/
{
LONG day; /*MJD of data*/
LONG fday; /*time in milliseconds after midnight*/
int mode; /*current mode -- see comments*/
double x; /*time difference measured in s*/
float rms; /*rms of values that make up x*/
float rms_avg; /*12-hour average of rms*/
int nval; /*number of values that make up x*/
double y; /*rate difference estimated in s/s*/
double d; /*drift of local rate in s/s**2 */
int srv; /*server number used in this cycle*/
int flags; /*state flags -- see comments*/
int waitn; /*nominal delay until next time in sec*/
int waitx; /*actual delay since last time in sec*/
double errx; /*error in time prediction */
double ybar; /*average of rate difference y */
int fcon; /*time constant for computing ybar*/
double sumerr; /*integral of errx with time constant fcon */
} ;
/*
parameter NUMSTATES sets the size of the push-down stack
of state vectors that are saved
*/
#define NUMSTATES 750
/*
parameter EVALPERIOD sets the interval after which the
performance of the algorithm is compared with the desired
goals and adjustments are made as needed. The default is
every day.
*/
#define EVALPERIOD 86400
/*
if parameter KERNEL is 1 then this machine has the modified
kernel routines originally written by David Mills. the machine
uses these kernel routines for leap second control, etc.
The relevant kernel parameters are defined in timex.h and
kern_ntptime.c. The parameters defined in that documentation are
used more or less for their original purposes, except for maxerror
and esterror, which are used as time-out and crash detectors.
the current version of the kernel software increments maxerr
by 512 each second. this version of autolock sets maxerr
to -512*(sleep time), where sleep time is the time until the
next calibration/estimation cycle. maxerr therefore counts back
towards zero and reaches 0 when the next calibration is due. It
contines to count upwards after that, and it can therefore be
used as a time-out indicator -- a positive value indicates that
something has gone wrong.
when a calibration cycle is started, the program sets esterror to
1 and maxerror to -512*20. Again, this is used as a time-out flag.
If maxerror becomes positive in this case with esterror non zero,
it means that the program has crashed or gotten stuck in the
network access department.
*/
#define KERNEL 1
/*
if LINUX is defined, then a number of small changes are made
to the algorithm. the most important is the use of the
semi-kernel routine adjtimex instead of the usual adjtime.
*/
/*
#define LINUX 1
*/
/*
it is very important that LINUX and KERNEL not be defined
at the same time. The two routines using similar structures,
but the names of the various members are different, and
lots of errors will be produced if you try to use both
together.
*/