timingApi
Data Structures | Defines | Typedefs | Functions
/afs/slac.stanford.edu/g/lcls/vol8/epics/R3.15.5-1.0/modules/timingApi/timingApi-git/timingApiSup/timingFifoApi.h File Reference
#include <stdint.h>
#include "timingApiTypes.h"

Go to the source code of this file.

Data Structures

struct  _BeamData
 The BeamData structure is used to retrieve beam related data from the timing stream. More...
struct  _EventTimingData
 The EventTimingData structure is used to retrieve synchronous data from the eventCode arrival time FIFO. More...

Defines

#define TS_INDEX_INIT   1000000
 TS_INDEX_INIT is a magic value that when used as the incr argument to timingFifoRead() tells it to set the index to the most recently arrived timing info.

Typedefs

typedef struct _BeamData BeamData
 The BeamData structure is used to retrieve beam related data from the timing stream.
typedef struct _EventTimingData EventTimingData
 The EventTimingData structure is used to retrieve synchronous data from the eventCode arrival time FIFO.
typedef void(* TimingEventCallback )(void *pUserPvt)
 TimingEventCallbacks get called w/ 1 parameter.

Functions

int timingFifoRead (unsigned int eventCode, int incr, uint64_t *index, EventTimingData *pTimingDataDest)
 The timingFifoRead() call allows a timingFifo client to access a FIFO queue of the last TS_INDEX_INIT eventCode arrival timestamps.
TimingPulseId timingGetLastFiducial ()
 timingGetLastFiducial returns lastfid, the last fiducial set by ISR.
TimingPulseId timingGetFiducialForTimeStamp (epicsTimeStamp timeStamp)
 timingGetFiducialForTimeStamp returns the fiducial that corresponds to the specified timestamp.
int timingGetCurTimeStamp (epicsTimeStamp *pTimeStampDest)
 Retrieve the most recent timestamp available.
int timingGetEventTimeStamp (epicsTimeStamp *pTimeStampDest, int eventCode)
 Retrieve the most recent timestamp and pulseId for the specified eventCode.
int timingGetBeamData (TimingBeamData *pBeamDataDest)
 Retrieve the most recent beam data.
int RegisterTimingEventCallback (TimingEventCallback callback, void *pUserPvt)
 RegisterTimingEventCallback is called by timing service clients to register a callback function for new timing events.

Define Documentation

#define TS_INDEX_INIT   1000000

TS_INDEX_INIT is a magic value that when used as the incr argument to timingFifoRead() tells it to set the index to the most recently arrived timing info.


Typedef Documentation

typedef struct _BeamData BeamData

The BeamData structure is used to retrieve beam related data from the timing stream.

The timing service must guarantee that all values returned via this structure are for the same pulse.

The EventTimingData structure is used to retrieve synchronous data from the eventCode arrival time FIFO.

The timing service must guarantee that all values returned via this structure are for the same pulse.

typedef void(* TimingEventCallback)(void *pUserPvt)

TimingEventCallbacks get called w/ 1 parameter.

  • pUserPvt is any pointer the callback client needs to establish context

Timing services will call this callback on every timing event received. Note that the timing service will only receive timing data for events it has subscribed to.


Function Documentation

int RegisterTimingEventCallback ( TimingEventCallback  callback,
void *  pUserPvt 
)

RegisterTimingEventCallback is called by timing service clients to register a callback function for new timing events.

The pUserPvt pointer can be used to establish context or set to 0 if not needed.

Timing services must support this RegisterTimingEventCallback() function and call the callback function once for each new timing event to be compliant w/ this timing BSA API.

Each callback client should get only one callback per beam pulse, even if there are multiple timing events per pulse, such as w/ LCLS-1. For LCLS-1 specifically, the timing callback should be made for event code 1, the fiducial.

The Timing service must support multiple timingEventCallbacks.

int timingFifoRead ( unsigned int  eventCode,
int  incr,
uint64_t *  index,
EventTimingData *  pTimingDataDest 
)

The timingFifoRead() call allows a timingFifo client to access a FIFO queue of the last TS_INDEX_INIT eventCode arrival timestamps.

Each client has their own index position in the queue which can be controlled w/ the incr argument.

Clients should not write directly to the index value.

  • incr==TS_INDEX_INIT: index set to the position of the most recent eventCode arrival.
  • incr!=TS_INDEX_INIT: index set to index+incr. Use +1/-1 to advance up and down the queue
  • incr==1: Set to 1 once synced to fetch one synced timestamp per sample indefinitely as long as you don't overrun or underrun.

The index is adjusted according to the incr argument before reading the eventCode arrival time info from the FIFO

FIFO underruns occur by trying to fetch another timestamp when you've already fetched the most recent one.

FIFO overruns occur by trying to fetch the next timestamp after it's position in the FIFO is reused by a new eventCode arrival time.

The timing service must guarantee that all values returned via this call are for the same pulse.

Return value: 0 on success -1 for NULL return ptrs -2 for invalid index -3 for FIFO overflow -4 for FIFO underflow.

These values are returned via ptr:

  • index ptr: 64 bit FIFO position. Adjusted according to the incr argument before reading the info from the FIFO
  • pTimingDataDest ptr: epicsTimeStamp, 64 bit fiducial, and 64 bit tsc
int timingGetBeamData ( TimingBeamData *  pBeamDataDest)

Retrieve the most recent beam data.

Return Beam data via this ptr

int timingGetCurTimeStamp ( epicsTimeStamp *  pTimeStampDest)

Retrieve the most recent timestamp available.

Return EPICS timestamp via this ptr

int timingGetEventTimeStamp ( epicsTimeStamp *  pTimeStampDest,
int  eventCode 
)

Retrieve the most recent timestamp and pulseId for the specified eventCode.

Which eventCode

Parameters:
pTimeStampDestReturn EPICS timestamp via this ptr
TimingPulseId timingGetFiducialForTimeStamp ( epicsTimeStamp  timeStamp)

timingGetFiducialForTimeStamp returns the fiducial that corresponds to the specified timestamp.

If the timing module cannot determine the correct fiducial, it returns TIMING_PULSEID_INVALID.

TimingPulseId timingGetLastFiducial ( )

timingGetLastFiducial returns lastfid, the last fiducial set by ISR.