21 return (scid[1] & 0x000F);
30 return ( (scid[0] & 0x0180) >> 7);
43 day = ttag[0] << 3 | ttag[1] >> 7;
44 msec = (ttag[1] & 0x7F) << 20 | (ttag[2] << 10) | ttag[3];
57 time_t utime = (time_t) usec;
60 trec = gmtime(&utime);
61 strftime(timeStr,
TIMELEN,
"%b %d %Y %H:%M:%S:000", trec);
75 *
msec = (ttag[1] & 0x7F) << 20 | (ttag[2] << 10) | ttag[3];
76 jday = (ttag[0] << 3 | ttag[1] >> 7) + 2449001;
79 rday =
jday - 2415020;
80 *year = 4 * rday / 1461;
82 *
day = rday - 1461 * (*year - 1) / 4 - 365;
94 return ( indx->rec[irec].tRanError ||
95 indx->rec[irec].tSeqError ||
96 indx->rec[irec].tDifError);
108 INT32 i3 =
MIN(irec + 1, indx->nrecs - 1);
110 if (irec < 0 || irec >= indx->nrecs)
114 while (i1 > 0 &&
timeError(indx, i1)) i1--;
115 while (i3 < indx->nrecs - 1 &&
timeError(indx, i3)) i3++;
122 if (indx->type !=
HRPT &&
123 (indx->rec[i2].mnftype != indx->rec[i1].mnftype ||
124 indx->rec[i2].mnftype != indx->rec[i3].mnftype)) {
130 (indx->rec[i3].time - indx->rec[i2].time >
DELSCENEGAC))
132 if ((irec == indx->nrecs - 1) &&
133 (indx->rec[i2].time - indx->rec[i1].time >
DELSCENEGAC))
136 (indx->rec[i3].time - indx->rec[i2].time <= 0))
138 if ((irec == indx->nrecs - 1) &&
139 (indx->rec[i2].time - indx->rec[i1].time <= 0))
144 if (indx->rec[i3].time < indx->rec[i1].time)
148 if ((indx->rec[i2].time < indx->rec[i1].time) ||
149 (indx->rec[i2].time > indx->rec[i3].time) ||
150 ((i1 != i2) && (indx->rec[i2].time == indx->rec[i1].time)))
170 if (irec < 0 || irec >= indx->nrecs)
176 i2 =
MIN(1, indx->nrecs - 1);
177 i3 =
MIN(2, indx->nrecs - 1);
178 }
else if (irec == indx->nrecs - 1) {
179 i3 = indx->nrecs - 1;
183 i1 =
MAX(irec - 1, 0);
185 i3 =
MIN(irec + 1, indx->nrecs - 1);
190 printf(
"Previous timing error(s) at frame %d\n", irec);
195 if (indx->rec[i1].scidError ||
196 indx->rec[i2].scidError ||
197 indx->rec[i3].scidError) {
198 printf(
"Previous SCID error(s) at frame %d\n", irec);
203 if (indx->rec[i2].mnftype != indx->rec[i1].mnftype ||
204 indx->rec[i2].mnftype != indx->rec[i3].mnftype) {
205 printf(
"Inconsistent frame types at frame %d\n", irec);
210 if (indx->rec[i2].mnftype ==
GACTYPE)
216 tdiff1 = indx->rec[i2].time - indx->rec[i1].time;
217 tdiff2 = indx->rec[i3].time - indx->rec[i2].time;
226 printf(
"%d %lf %lf\n", irec, tdiff1, tdiff2);
250 if (irec < 0 || irec >= indx->nrecs)
256 i2 =
MIN(1, indx->nrecs - 1);
257 i3 =
MIN(2, indx->nrecs - 1);
258 }
else if (irec == indx->nrecs - 1) {
259 i3 = indx->nrecs - 1;
263 i1 =
MAX(irec - 1, 0);
265 i3 =
MIN(irec + 1, indx->nrecs - 1);
269 if (indx->rec[i2].mnftype ==
GACTYPE &&
270 (indx->rec[i3].mnftype != indx->rec[i1].mnftype)) {
275 if (indx->rec[i2].mnftype ==
GACTYPE) {
284 tdiff1 = indx->rec[i2].time - indx->rec[i1].time;
285 tdiff2 = indx->rec[i3].time - indx->rec[i2].time;
288 if (indx->type ==
GAC && (tdiff1 > DelScene || tdiff2 > DelScene))
292 terror1 = fmod(tdiff1, DelTime);
293 terror2 = fmod(tdiff2, DelTime);
294 terror1 =
ABS(terror1);
295 terror2 =
ABS(terror2);
296 if (terror1 > DelTime / 2) terror1 =
ABS(terror1 - DelTime);
297 if (terror2 > DelTime / 2) terror2 =
ABS(terror2 - DelTime);
304 printf(
"Time Difference Error at Frame %d: %lf %lf %lf\n",
305 irec, tdiff1, terror1, terror2);
331 if (irec < 0 || irec >= indx->nrecs)
337 i2 =
MIN(1, indx->nrecs - 1);
338 i3 =
MIN(2, indx->nrecs - 1);
339 }
else if (irec == indx->nrecs - 1) {
340 i3 = indx->nrecs - 1;
344 i1 =
MAX(irec - 1, 0);
346 i3 =
MIN(irec + 1, indx->nrecs - 1);
350 if (indx->rec[i2].mnftype ==
GACTYPE &&
351 (indx->rec[i3].mnftype != indx->rec[i1].mnftype)) {
356 if (indx->rec[i2].mnftype ==
GACTYPE) {
365 tdiff1 = indx->rec[i2].time - indx->rec[i1].time;
366 tdiff2 = indx->rec[i3].time - indx->rec[i2].time;
369 if (indx->type ==
GAC && (tdiff1 > DelScene || tdiff2 > DelScene))
373 terror1 = fmod(tdiff1, DelTime);
374 if (tdiff1 < DelTime)
377 terror2 = fmod(tdiff2, DelTime);
378 if (tdiff2 < DelTime)
387 printf(
"Time Shift at Frame %d: %lf of %lf secs\n",
388 irec, tdiff1, *shiftval);
402 BYTE msghdr[6] = {225, 1, 193, 28, 0, 3};
405 for (
i = 0;
i < 6;
i++)
406 if (hdr[
i + 2] != msghdr[
i])
456 BYTE mask[] = {3, 255, 0, 0, 3, 255, 0, 0, 3, 255, 0, 0, 3, 255};
462 memcpy(scid, &mnf[
O_SCID],
sizeof (scid));
471 }
else if (mnftype ==
LACTYPE) {
482 for (
j = 0;
j < 14;
j++) {
515 BYTE mask[] = {3, 255, 3, 255, 0, 0, 0, 0, 3, 255, 3, 255, 0, 0};
521 memcpy(scid, &mnf[
O_SCID],
sizeof (scid));
530 }
else if (mnftype ==
LACTYPE) {
541 for (
j = 0;
j < 14;
j++) {
576 memcpy(scid, &mnf[
O_SCID],
sizeof (scid));
583 }
else if (mnftype ==
LACTYPE) {