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;
101 return (buf.st_size);
110 return ( indx->rec[irec].tRanError ||
111 indx->rec[irec].tSeqError ||
112 indx->rec[irec].tDifError);
124 INT32 i3 =
MIN(irec + 1, indx->nrecs - 1);
126 if (irec < 0 || irec >= indx->nrecs)
130 while (i1 > 0 &&
timeError(indx, i1)) i1--;
131 while (i3 < indx->nrecs - 1 &&
timeError(indx, i3)) i3++;
138 if (indx->type !=
HRPT &&
139 (indx->rec[i2].mnftype != indx->rec[i1].mnftype ||
140 indx->rec[i2].mnftype != indx->rec[i3].mnftype)) {
146 (indx->rec[i3].time - indx->rec[i2].time >
DELSCENEGAC))
148 if ((irec == indx->nrecs - 1) &&
149 (indx->rec[i2].time - indx->rec[i1].time >
DELSCENEGAC))
152 (indx->rec[i3].time - indx->rec[i2].time <= 0))
154 if ((irec == indx->nrecs - 1) &&
155 (indx->rec[i2].time - indx->rec[i1].time <= 0))
160 if (indx->rec[i3].time < indx->rec[i1].time)
164 if ((indx->rec[i2].time < indx->rec[i1].time) ||
165 (indx->rec[i2].time > indx->rec[i3].time) ||
166 ((i1 != i2) && (indx->rec[i2].time == indx->rec[i1].time)))
186 if (irec < 0 || irec >= indx->nrecs)
192 i2 =
MIN(1, indx->nrecs - 1);
193 i3 =
MIN(2, indx->nrecs - 1);
194 }
else if (irec == indx->nrecs - 1) {
195 i3 = indx->nrecs - 1;
199 i1 =
MAX(irec - 1, 0);
201 i3 =
MIN(irec + 1, indx->nrecs - 1);
206 printf(
"Previous timing error(s) at frame %d\n", irec);
211 if (indx->rec[i1].scidError ||
212 indx->rec[i2].scidError ||
213 indx->rec[i3].scidError) {
214 printf(
"Previous SCID error(s) at frame %d\n", irec);
219 if (indx->rec[i2].mnftype != indx->rec[i1].mnftype ||
220 indx->rec[i2].mnftype != indx->rec[i3].mnftype) {
221 printf(
"Inconsistent frame types at frame %d\n", irec);
226 if (indx->rec[i2].mnftype ==
GACTYPE)
232 tdiff1 = indx->rec[i2].time - indx->rec[i1].time;
233 tdiff2 = indx->rec[i3].time - indx->rec[i2].time;
242 printf(
"%d %lf %lf\n", irec, tdiff1, tdiff2);
266 if (irec < 0 || irec >= indx->nrecs)
272 i2 =
MIN(1, indx->nrecs - 1);
273 i3 =
MIN(2, indx->nrecs - 1);
274 }
else if (irec == indx->nrecs - 1) {
275 i3 = indx->nrecs - 1;
279 i1 =
MAX(irec - 1, 0);
281 i3 =
MIN(irec + 1, indx->nrecs - 1);
285 if (indx->rec[i2].mnftype ==
GACTYPE &&
286 (indx->rec[i3].mnftype != indx->rec[i1].mnftype)) {
291 if (indx->rec[i2].mnftype ==
GACTYPE) {
300 tdiff1 = indx->rec[i2].time - indx->rec[i1].time;
301 tdiff2 = indx->rec[i3].time - indx->rec[i2].time;
304 if (indx->type ==
GAC && (tdiff1 > DelScene || tdiff2 > DelScene))
308 terror1 = fmod(tdiff1, DelTime);
309 terror2 = fmod(tdiff2, DelTime);
310 terror1 =
ABS(terror1);
311 terror2 =
ABS(terror2);
312 if (terror1 > DelTime / 2) terror1 =
ABS(terror1 - DelTime);
313 if (terror2 > DelTime / 2) terror2 =
ABS(terror2 - DelTime);
320 printf(
"Time Difference Error at Frame %d: %lf %lf %lf\n",
321 irec, tdiff1, terror1, terror2);
347 if (irec < 0 || irec >= indx->nrecs)
353 i2 =
MIN(1, indx->nrecs - 1);
354 i3 =
MIN(2, indx->nrecs - 1);
355 }
else if (irec == indx->nrecs - 1) {
356 i3 = indx->nrecs - 1;
360 i1 =
MAX(irec - 1, 0);
362 i3 =
MIN(irec + 1, indx->nrecs - 1);
366 if (indx->rec[i2].mnftype ==
GACTYPE &&
367 (indx->rec[i3].mnftype != indx->rec[i1].mnftype)) {
372 if (indx->rec[i2].mnftype ==
GACTYPE) {
381 tdiff1 = indx->rec[i2].time - indx->rec[i1].time;
382 tdiff2 = indx->rec[i3].time - indx->rec[i2].time;
385 if (indx->type ==
GAC && (tdiff1 > DelScene || tdiff2 > DelScene))
389 terror1 = fmod(tdiff1, DelTime);
390 if (tdiff1 < DelTime)
393 terror2 = fmod(tdiff2, DelTime);
394 if (tdiff2 < DelTime)
403 printf(
"Time Shift at Frame %d: %lf of %lf secs\n",
404 irec, tdiff1, *shiftval);
418 BYTE msghdr[6] = {225, 1, 193, 28, 0, 3};
421 for (
i = 0;
i < 6;
i++)
422 if (hdr[
i + 2] != msghdr[
i])
472 BYTE mask[] = {3, 255, 0, 0, 3, 255, 0, 0, 3, 255, 0, 0, 3, 255};
478 memcpy(scid, &mnf[
O_SCID],
sizeof (scid));
487 }
else if (mnftype ==
LACTYPE) {
498 for (
j = 0;
j < 14;
j++) {
531 BYTE mask[] = {3, 255, 3, 255, 0, 0, 0, 0, 3, 255, 3, 255, 0, 0};
537 memcpy(scid, &mnf[
O_SCID],
sizeof (scid));
546 }
else if (mnftype ==
LACTYPE) {
557 for (
j = 0;
j < 14;
j++) {
592 memcpy(scid, &mnf[
O_SCID],
sizeof (scid));
599 }
else if (mnftype ==
LACTYPE) {