|
Typedef for struct _EMP_hdr.
- Goals
- This structure attempts to provide two pieces of information
- The number of events that were used to accumulate this sample
- Unique identification, both by time and event sequence number, of the events bracketing the opening and closing of this datagram. This defines the span of the accumulated statistics.
- Accessing Information
- The depth of the structure definitions makes the pathnames to individual field members somewhat unwieldy. However, binding information into well-defined structures, allows one to write utility programs that consume these structures as single arguments. This is the preferred usage.
- Usage, Direct Access
- A sample usage is
beg_evt_sequence = hdr->evt.beg.seq;
end_evt_sequence = hdr->evt.end.seq;
beg_seconds = hdr->evt.beg.timetones.cur.secs;
end_seconds = hdr->evt.end.timetones.cur.secs;
elasped_seconds = beg_seconds - end_seconds;
events_seen = end_evt_sequence - beg_evt_sequence;
events_accumulated = hdr->nevts;
- Usage, Utility Access
- Discovering the absolute time beyond the second accurary requires using the all information in the timetone structures. The full treatment, covering error cases, is beyond the scope of a simple example. The following example assumes, no errors and no overflows. The easies way to code a utility function
unsigned long long int get_event_time (const EMP_hdrEvt *evt)
{
unsigned int curGemStrobe = evt->timetones.cur.gemStrobe & TICKS;
unsigned int prvGemStrobe = evt->timetones.cur.gemStrobe & TICKS;
unsigned int deltaTicks = curGemStrobe - prvGemStrobe;
unsigned int curGemSecs = evt->timetones.cur.secs;
unsigned int prvGemSecs = evt->timetones.prv.secs;
unsigned int deltaNsecs = ONE_BILLION * (curGemSecs - prvGemSecs);
unsigned int curGemClock = evt->gemClock & TICKS;
unsigned int elapsedTicks = curGemClock - curGemStrobe;
unsigned long long int time;
time = ONE_BILLION * secs + (elapsedTicks * deltaNsecs) / deltaTicks;
return time;
- Armed with this utility one then does
beg_time = get_event_time (&hdr->span.beg);
end_time = get_event_time (&hdr->span.end);
elapsed_time = end_time - beg_time;
- Warning:
- The above piece of code is for purposes of illustration only. It assumes
- No error conditions,
- No overflows
- That an extrapolation using the frequency/period of the last 1PPS interval (versus an interpolation or some other fancier method of predicting the period for this interval) is adequate.
|