ET System  16.5
All Data Structures Files Functions Variables Typedefs Macros Modules Pages
Fifo

These routines use the ET system as a FIFO. More...

Functions

int et_fifo_openProducer (et_sys_id id, et_fifo_id *fid, const int *bufIds, int idCount)
 
int et_fifo_openConsumer (et_sys_id id, et_fifo_id *fid)
 
void et_fifo_close (et_fifo_id fid)
 Routine to close the fifo handle opened with et_fifo_openProducer or et_fifo_openConsumer. More...
 
et_fifo_entryet_fifo_entryCreate (et_fifo_id fid)
 Routine to allocate a structure holding a fifo entry (array of ET events) associated with the given fifo id. More...
 
void et_fifo_freeEntry (et_fifo_entry *entry)
 Routine to free a fifo entry created with et_fifo_entryCreate. More...
 
int et_fifo_newEntry (et_fifo_id fid, et_fifo_entry *entry)
 This routine is called when a user wants an array of related, empty buffers from the ET system into which data can be placed. More...
 
int et_fifo_newEntryTO (et_fifo_id fid, et_fifo_entry *entry, struct timespec *deltatime)
 This routine is called when a user wants an array of related, empty buffers from the ET system into which data can be placed. More...
 
int et_fifo_getEntry (et_fifo_id fid, et_fifo_entry *entry)
 This routine is called when a user wants an array of related, data-filled buffers from the ET system. More...
 
int et_fifo_getEntryTO (et_fifo_id fid, et_fifo_entry *entry, struct timespec *deltatime)
 This routine is called when a user wants an array of related, data-filled buffers from the ET system. More...
 
int et_fifo_putEntry (et_fifo_entry *entry)
 This routine is called when a user wants to place an array of related, data-filled buffers (single FIFO entry) back into the ET system. More...
 
et_event ** et_fifo_getBufs (et_fifo_entry *entry)
 This routine gives access to the ET events or buffers in a fifo entry obtained by calling either et_fifo_getEntry, et_fifo_getEntryTO, et_fifo_newEntry, or et_fifo_newEntryTO. More...
 
int et_fifo_getEntryCount (et_fifo_id id)
 This routine gets the max number of fifo entries possibly available to consumer. More...
 
int et_fifo_getFillLevel (et_fifo_id id)
 
size_t et_fifo_getBufSize (et_fifo_id id)
 This routine gets the max size of each buffer in bytes. More...
 
int et_fifo_getEntryCapacity (et_fifo_id id)
 This routine gets the max number of buffers in each FIFO entry. More...
 
int et_fifo_getIdCount (et_fifo_id id)
 This routine gets the number of buffers assigned an id in each FIFO entry. More...
 
int et_fifo_getBufIds (et_fifo_id id, int *bufIds)
 This routine gets the array of ids assigned to buffers in each FIFO entry. More...
 
void et_fifo_setId (et_event *ev, int id)
 This routine sets an id value associated with this ET event/buffer. More...
 
int et_fifo_getId (et_event *ev)
 This routine gets an id value associated with this ET event/buffer. More...
 
void et_fifo_setHasData (et_event *ev, int hasData)
 This routine sets whether this ET event has data in it. More...
 
int et_fifo_hasData (et_event *ev)
 This routine gets whether this ET event has data in it or not. More...
 
int et_fifo_allHaveData (et_fifo_id id, et_fifo_entry *entry, int *incompleteBufs, size_t *incompleteBytes)
 This routine gets whether all events (associated with an id) in the given ET fifo entry have data in it or not. More...
 
et_eventet_fifo_getBuf (int id, et_fifo_entry *entry)
 Find the event/buffer in the fifo entry corresponding to the given id. More...
 

Detailed Description

These routines use the ET system as a FIFO.

Function Documentation

◆ et_fifo_allHaveData()

int et_fifo_allHaveData ( et_fifo_id  id,
et_fifo_entry entry,
int *  incompleteBufs,
size_t *  incompleteBytes 
)

This routine gets whether all events (associated with an id) in the given ET fifo entry have data in it or not.

This routine is geared towards ejfat and the reassembly of UDP packets into buffers. It returns, in its args, how many buffers and bytes are associated with incompletely reassembled data.

Parameters
idET fifo handle.
entryET fifo entry.
incompleteBufsfilled with # of bufs not listed has having data (having incomplete data).
incompleteBytesfilled with # of bytes contained in events not listed has having data (having incomplete data).
Returns
1 if all events have data, 0 if not, ET_ERROR if bad arg(s).

References et_fifo_entry_t::bufs, et_event_t::control, ET_ERROR, et_event_getlength(), and et_fifo_context_t::idCount.

◆ et_fifo_close()

void et_fifo_close ( et_fifo_id  fid)

Routine to close the fifo handle opened with et_fifo_openProducer or et_fifo_openConsumer.

Closing the ET system must be done separately.

Parameters
fidfifo id.

References et_fifo_context_t::attId, et_fifo_context_t::bufIds, et_station_detach(), and et_fifo_context_t::openId.

◆ et_fifo_entryCreate()

et_fifo_entry* et_fifo_entryCreate ( et_fifo_id  fid)

Routine to allocate a structure holding a fifo entry (array of ET events) associated with the given fifo id.

This memory must be freed with et_fifo_freeEntry.

Parameters
fidfifo id.
Returns
pointer to allocated fifo entry. NULL if out of mem.

References et_fifo_entry_t::bufs, et_fifo_context_t::capacity, and et_fifo_entry_t::fid.

◆ et_fifo_freeEntry()

void et_fifo_freeEntry ( et_fifo_entry entry)

Routine to free a fifo entry created with et_fifo_entryCreate.

Parameters
entrypointer to fifo entry.

References et_fifo_entry_t::bufs.

◆ et_fifo_getBuf()

et_event* et_fifo_getBuf ( int  id,
et_fifo_entry entry 
)

Find the event/buffer in the fifo entry corresponding to the given id.

If none, get the first unused buffer, assign it that id, and return it. The id value for an event is stored in its first control integer. NOT threadsafe.

Parameters
iddata source id.
entryfifo entry.
Returns
buffer labelled with id or first one that's unused. NULL if no bufs are available.

References et_fifo_entry_t::bufs, et_fifo_context_t::capacity, et_event_t::control, and et_fifo_entry_t::fid.

◆ et_fifo_getBufIds()

int et_fifo_getBufIds ( et_fifo_id  id,
int *  bufIds 
)

This routine gets the array of ids assigned to buffers in each FIFO entry.

The same as the bufIds argument of et_fifo_openProducer. Assumes the user is passing in an array of length found by calling et_fifo_getIdCount.

Parameters
idET fifo handle.
bufIdsarray of buffer id numbers.
Returns
number of buffers assigned an id in each FIFO entry, or ET_ERROR if bad arg(s).

References et_fifo_context_t::bufIds, ET_ERROR, and et_fifo_context_t::idCount.

◆ et_fifo_getBufs()

et_event** et_fifo_getBufs ( et_fifo_entry entry)

This routine gives access to the ET events or buffers in a fifo entry obtained by calling either et_fifo_getEntry, et_fifo_getEntryTO, et_fifo_newEntry, or et_fifo_newEntryTO.

The size of the returned array can be found by calling et_fifo_getEntryCapacity.

Parameters
entryET fifo entry.
Returns
array of pointers to et_event structures or NULL if bad arg.

References et_fifo_entry_t::bufs.

◆ et_fifo_getBufSize()

size_t et_fifo_getBufSize ( et_fifo_id  id)

This routine gets the max size of each buffer in bytes.

Parameters
idET fifo handle.
Returns
size of each buffer in bytes, or ET_ERROR if bad arg.

References ET_ERROR, and et_fifo_context_t::evSize.

◆ et_fifo_getEntry()

int et_fifo_getEntry ( et_fifo_id  fid,
et_fifo_entry entry 
)

This routine is called when a user wants an array of related, data-filled buffers from the ET system.

This routine will block until the buffers become available. Access the buffers by calling et_fifo_getBufs. Each call to this routine MUST be accompanied by a following call to et_fifo_putEntry!

See also
For more insight, see the doxygen doc on et_events_get.
Parameters
fidET fifo handle.
entrypointer to fifo entry to be filled with data from next fifo element.
Returns
ET_OK if successful.
ET_ERROR if bad argument(s), or not a fifo consumer, or attachment not active, or did not get the full number of buffers comprising one fifo entry.
ET_ERROR_NOMEM if cannot allocate memory.
ET_ERROR_CLOSED if et_close already called.
ET_ERROR_REMOTE for a memory allocation error of a remote user.
ET_ERROR_READ for a remote user's network read error.
ET_ERROR_WRITE for a remote user's network write error.
ET_ERROR_DEAD if ET system is dead.
ET_ERROR_WAKEUP if told to stop sleeping while trying to get an event.

References et_fifo_context_t::attId, et_fifo_entry_t::bufs, et_fifo_context_t::capacity, ET_ERROR, et_events_get(), et_logmsg(), ET_OK, ET_SLEEP, et_fifo_context_t::openId, and et_fifo_context_t::producer.

◆ et_fifo_getEntryCapacity()

int et_fifo_getEntryCapacity ( et_fifo_id  id)

This routine gets the max number of buffers in each FIFO entry.

Parameters
idET fifo handle.
Returns
max number of buffers in each FIFO entry, or ET_ERROR if bad arg.

References et_fifo_context_t::capacity, and ET_ERROR.

◆ et_fifo_getEntryCount()

int et_fifo_getEntryCount ( et_fifo_id  id)

This routine gets the max number of fifo entries possibly available to consumer.

Parameters
idET fifo handle.
Returns
the total number of entries existing in the fifo.
ET_ERROR if bad arg.

References ET_ERROR, and et_fifo_context_t::userEntries.

◆ et_fifo_getEntryTO()

int et_fifo_getEntryTO ( et_fifo_id  fid,
et_fifo_entry entry,
struct timespec *  deltatime 
)

This routine is called when a user wants an array of related, data-filled buffers from the ET system.

This routine will block until it times out. Access the buffers by calling et_fifo_getBufs. Each call to this routine MUST be accompanied by a following call to et_fifo_putEntry!

See also
For more insight, see the doxygen doc on et_events_get.
Parameters
fidET fifo handle.
entrypointer to fifo entry to be filled with data from next fifo element.
deltatimetime to wait before returning.
Returns
ET_OK if successful.
ET_ERROR if bad argument(s), or not a fifo consumer, or attachment not active, or did not get the full number of buffers comprising one fifo entry.
ET_ERROR_NOMEM if cannot allocate memory.
ET_ERROR_CLOSED if et_close already called.
ET_ERROR_REMOTE for a memory allocation error of a remote user.
ET_ERROR_READ for a remote user's network read error.
ET_ERROR_WRITE for a remote user's network write error.
ET_ERROR_DEAD if ET system is dead.
ET_ERROR_WAKEUP if told to stop sleeping while trying to get an event.
ET_ERROR_TIMEOUT if timeout.

References et_fifo_context_t::attId, et_fifo_entry_t::bufs, et_fifo_context_t::capacity, ET_ERROR, et_events_get(), et_logmsg(), ET_OK, ET_TIMED, et_fifo_context_t::openId, and et_fifo_context_t::producer.

◆ et_fifo_getFillLevel()

int et_fifo_getFillLevel ( et_fifo_id  id)

This routine gets the number of fifo entries containing unconsumed data available to the consumer. This is the fill level of the fifo. This should be compared to the max number of fifo entries obtained by calling et_fifo_getEntryCount.

Note: there are actually more entries in the ET system, 5% with at least 2, that exist but cannot be placed in the Users station input list due to its nonblocking nature.

Parameters
idET fifo handle.
Returns
number of fifo entries filled with unconsumed data.
ET_ERROR if bad arg.
ET_ERROR_CLOSED if et_close already called.
ET_ERROR_DEAD if ET system is dead.
ET_ERROR_READ for a remote user's network read error.
ET_ERROR_WRITE for a remote user's network write error.

References ET_ERROR, ET_OK, et_station_getinputcount_rt(), et_fifo_context_t::openId, and et_fifo_context_t::userStatId.

◆ et_fifo_getId()

int et_fifo_getId ( et_event ev)

This routine gets an id value associated with this ET event/buffer.

Parameters
evET event.
Returns
id of this event, or ET_ERROR if ev = NULL.

References et_event_t::control, and ET_ERROR.

◆ et_fifo_getIdCount()

int et_fifo_getIdCount ( et_fifo_id  id)

This routine gets the number of buffers assigned an id in each FIFO entry.

The same as the idCount argument of et_fifo_openProducer.

Parameters
idET fifo handle.
Returns
number of buffers assigned an id in each FIFO entry, or ET_ERROR if bad arg.

References ET_ERROR, and et_fifo_context_t::idCount.

◆ et_fifo_hasData()

int et_fifo_hasData ( et_event ev)

This routine gets whether this ET event has data in it or not.

Parameters
evET event.
Returns
1 if this event as data, 0 if it does not, ET_ERROR if arg is null.

References et_event_t::control, and ET_ERROR.

◆ et_fifo_newEntry()

int et_fifo_newEntry ( et_fifo_id  fid,
et_fifo_entry entry 
)

This routine is called when a user wants an array of related, empty buffers from the ET system into which data can be placed.

This routine will block until the buffers become available. Access the buffers by calling et_fifo_getBufs. Each call to this routine MUST be accompanied by a following call to et_fifo_putEntry!

See also
For more insight, see the doxygen doc on et_events_new.
Parameters
fidfifo id.
entrypointer to fifo entry to be filled with empty fifo entry.
Returns
ET_OK if successful.
ET_ERROR if bad argument(s), or not a fifo producer, or attachment not active, or did not get the full number of buffers comprising one fifo entry.
ET_ERROR_NOMEM if cannot allocate memory.
ET_ERROR_CLOSED if et_close already called.
ET_ERROR_REMOTE for a memory allocation error of a remote user.
ET_ERROR_READ for a remote user's network read error.
ET_ERROR_WRITE for a remote user's network write error.
ET_ERROR_DEAD if ET system is dead.
ET_ERROR_WAKEUP if told to stop sleeping while trying to get an event.

References et_fifo_context_t::attId, et_fifo_context_t::bufIds, et_fifo_entry_t::bufs, et_fifo_context_t::capacity, et_event_t::control, ET_ERROR, et_events_new(), et_logmsg(), ET_OK, ET_SLEEP, et_fifo_context_t::evSize, et_fifo_context_t::idCount, et_event_t::length, et_fifo_context_t::openId, and et_fifo_context_t::producer.

◆ et_fifo_newEntryTO()

int et_fifo_newEntryTO ( et_fifo_id  fid,
et_fifo_entry entry,
struct timespec *  deltatime 
)

This routine is called when a user wants an array of related, empty buffers from the ET system into which data can be placed.

This routine will block until it times out. Access the buffers by calling et_fifo_getBufs. Each call to this routine MUST be accompanied by a following call to et_fifo_putEntry!

See also
For more insight, see the doxygen doc on et_events_new.
Parameters
fidfifo id.
entrypointer to fifo entry to be filled with empty fifo entry.
deltatimetime to wait before returning.
Returns
ET_OK if successful.
ET_ERROR if bad argument(s), or not a fifo producer, or attachment not active, or did not get the full number of buffers comprising one fifo entry.
ET_ERROR_NOMEM if cannot allocate memory.
ET_ERROR_NOMEM if cannot allocate memory.
ET_ERROR_CLOSED if et_close already called.
ET_ERROR_REMOTE for a memory allocation error of a remote user.
ET_ERROR_READ for a remote user's network read error.
ET_ERROR_WRITE for a remote user's network write error.
ET_ERROR_DEAD if ET system is dead.
ET_ERROR_WAKEUP if told to stop sleeping while trying to get an event.
ET_ERROR_TIMEOUT if timeout.

References et_fifo_context_t::attId, et_fifo_context_t::bufIds, et_fifo_entry_t::bufs, et_fifo_context_t::capacity, et_event_t::control, ET_ERROR, et_events_new(), et_logmsg(), ET_OK, ET_TIMED, et_fifo_context_t::evSize, et_fifo_context_t::idCount, et_event_t::length, et_fifo_context_t::openId, and et_fifo_context_t::producer.

◆ et_fifo_openConsumer()

int et_fifo_openConsumer ( et_sys_id  id,
et_fifo_id fid 
)

This routine creates a handle (et_fifo_id) with which to interact with an ET system by treating it as a FIFO in which each element has multiple buffers (events). The caller acts only as a data consumer , with calls to et_fifo_getEntry allowed, but calls to et_fifo_newEntry forbidden.

In order for this to work, the ET system being used must be started by et_start_fifo, NOT et_start.

Parameters
idid of an opened ET system.
fidpointer to fifo id which gets filled in if ET system successfully opened and defined in a fifo-consistent manner.
Returns
ET_OK if successful.
ET_ERROR if either id or fid is NULL, or id not initialized, or number of events not multiple of fifo entries.
ET_ERROR_NOMEM if memory cannot be allocated.
ET_ERROR_CLOSED if et_close already called.
ET_ERROR_DEAD if ET system is dead.
ET_ERROR_READ for a remote user's network read error.
ET_ERROR_WRITE for a remote user's network write error.
ET_ERROR_TOOMANY if the existing number of attachments to GC or Users is already equal to the station or system limit. If there are more than 2 stations.
ET_ERROR_REMOTE for a memory allocation error of a remote user

◆ et_fifo_openProducer()

int et_fifo_openProducer ( et_sys_id  id,
et_fifo_id fid,
const int *  bufIds,
int  idCount 
)

This routine creates a handle (et_fifo_id) with which to interact with an ET system by treating it as a FIFO in which each element has multiple buffers (events). The caller acts only as a data producer, with calls to et_fifo_newEntry allowed, but calls to et_fifo_getEntry forbidden.

In order for this to work, the ET system being used must be started by et_start_fifo, NOT et_start.

Parameters
idid of an opened ET system.
fidpointer to fifo id which gets filled in if ET system successfully opened and defined in a fifo-consistent manner.
bufIdsarray of ids, assign one to each buffer of each fifo entry. If more provided than needed, only the first are used.
idCountnumber of ints in bufIds array.
Returns
ET_OK if successful.
ET_ERROR if either id or fid is NULL, or id not initialized, or number of events not multiple of fifo entries.
ET_ERROR_BADARG if bufId is NULL or idCount = 0.
ET_ERROR_NOMEM if memory cannot be allocated.
ET_ERROR_CLOSED if et_close already called.
ET_ERROR_DEAD if ET system is dead.
ET_ERROR_READ for a remote user's network read error.
ET_ERROR_WRITE for a remote user's network write error.
ET_ERROR_TOOMANY if the existing number of attachments to GC or Users is already equal to the station or system limit (unlikely as this is 100). If the number of ids given (bidCount) is more that fifo entry capacity. If there are more than 2 stations.
ET_ERROR_REMOTE for a memory allocation error of a remote user

◆ et_fifo_putEntry()

int et_fifo_putEntry ( et_fifo_entry entry)

This routine is called when a user wants to place an array of related, data-filled buffers (single FIFO entry) back into the ET system.

This must be called after calling either et_fifo_getEntry, et_fifo_getEntryTO, et_fifo_newEntry, or et_fifo_newEntryTO. This routine will never block.

See also
For more insight, see the doxygen doc on et_events_put.
Parameters
entryfifo entry to release back to ET.
Returns
ET_OK if successful.
ET_ERROR if bad argument or event data length > ET event size.
ET_ERROR_CLOSED if et_close already called
ET_ERROR_READ for a remote user's network read error
ET_ERROR_WRITE for a remote user's network write error
ET_ERROR_DEAD if ET system is dead
ET_ERROR_REMOTE bad pointer to data or memory allocation error of a remote user

References et_fifo_context_t::attId, et_fifo_entry_t::bufs, et_fifo_context_t::capacity, ET_ERROR, et_events_put(), ET_OK, et_fifo_entry_t::fid, and et_fifo_context_t::openId.

◆ et_fifo_setHasData()

void et_fifo_setHasData ( et_event ev,
int  hasData 
)

This routine sets whether this ET event has data in it.

Stored in event's second control word.

Parameters
evET event.
hasData1 if this event as data, 0 if it does not.

References et_event_t::control.

◆ et_fifo_setId()

void et_fifo_setId ( et_event ev,
int  id 
)

This routine sets an id value associated with this ET event/buffer.

Stored in event's first control word. This should never be used.

Parameters
evET event.
idid of this event.

References et_event_t::control.