ET System  16.5
All Data Structures Files Functions Variables Typedefs Macros Modules Pages
et_fifo.h
Go to the documentation of this file.
1 //
2 // Copyright 2022, Jefferson Science Associates, LLC.
3 // Subject to the terms in the LICENSE file found in the top-level directory.
4 //
5 // EPSCI Group
6 // Thomas Jefferson National Accelerator Facility
7 // 12000, Jefferson Ave, Newport News, VA 23606
8 // (757)-269-7100
9 
10 
11 #ifndef ET_FIFO_H_
12 #define ET_FIFO_H_
13 
14 #include <stdio.h>
15 #include <sys/types.h>
16 #include <sys/mman.h>
17 #include <time.h>
18 #include <sys/time.h>
19 
20 #include "et.h"
21 
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 
28 typedef void *et_fifo_id;
32 typedef struct et_fifo_context_t {
33  size_t evSize;
34  int evCount;
35  int entries;
37  int producer;
38  int capacity;
43  int idCount;
44  int *bufIds;
46 
47 
49 typedef struct et_fifo_entry_t {
53 
54 
55 extern int et_fifo_openProducer(et_sys_id fid, et_fifo_id *fifoId, const int *bufIds, int idCount);
56 extern int et_fifo_openConsumer(et_sys_id fid, et_fifo_id *fifoId);
57 extern void et_fifo_close(et_fifo_id fid);
58 
59 extern int et_fifo_newEntry(et_fifo_id fid, et_fifo_entry *entry);
60 extern int et_fifo_newEntryTO(et_fifo_id fid, et_fifo_entry *entry, struct timespec *deltatime);
61 
62 extern int et_fifo_getEntry(et_fifo_id fid, et_fifo_entry *entry);
63 extern int et_fifo_getEntryTO(et_fifo_id fid, et_fifo_entry *entry, struct timespec *deltatime);
64 
65 extern int et_fifo_putEntry(et_fifo_entry *entry);
66 extern int et_fifo_allHaveData(et_fifo_id id, et_fifo_entry *entry,
67  int *incompleteBufs, size_t *incompleteBytes);
68 
69 extern int et_fifo_getEntryCount(et_fifo_id id);
70 extern int et_fifo_getFillLevel(et_fifo_id id);
71 
72 extern size_t et_fifo_getBufSize(et_fifo_id fid);
73 extern int et_fifo_getEntryCapacity(et_fifo_id fid);
74 
75 extern et_event** et_fifo_getBufs(et_fifo_entry *entry);
76 extern et_event* et_fifo_getBuf(int id, et_fifo_entry *entry);
77 
78 extern void et_fifo_setId(et_event *ev, int id);
79 extern int et_fifo_getId(et_event *ev);
80 
81 extern void et_fifo_setHasData(et_event *ev, int hasData);
82 extern int et_fifo_hasData(et_event *ev);
83 
84 extern int et_fifo_getIdCount(et_fifo_id id);
85 extern int et_fifo_getBufIds(et_fifo_id id, int *bufIds);
86 
88 extern void et_fifo_freeEntry(et_fifo_entry *entry);
89 
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif
void * et_sys_id
ET system id.
Definition: et.h:339
int et_att_id
ET attachment id.
Definition: et.h:346
int et_stat_id
ET station id.
Definition: et.h:344
struct et_fifo_context_t et_fifo_ctx
Structure to hold the context of a fifo connection to ET.
struct et_fifo_entry_t et_fifo_entry
Structure to hold the a fifo entry obtained from ET.
void * et_fifo_id
ET fifo id.
Definition: et_fifo.h:28
void et_fifo_close(et_fifo_id fid)
Routine to close the fifo handle opened with et_fifo_openProducer or et_fifo_openConsumer.
Definition: et_fifo.c:350
void et_fifo_setId(et_event *ev, int id)
This routine sets an id value associated with this ET event/buffer.
Definition: et_fifo.c:775
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.
Definition: et_fifo.c:594
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 w...
Definition: et_fifo.c:487
int et_fifo_getId(et_event *ev)
This routine gets an id value associated with this ET event/buffer.
Definition: et_fifo.c:786
int et_fifo_getEntryCount(et_fifo_id id)
This routine gets the max number of fifo entries possibly available to consumer.
Definition: et_fifo.c:676
int et_fifo_openProducer(et_sys_id fid, et_fifo_id *fifoId, const int *bufIds, int idCount)
Definition: et_fifo.c:303
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.
Definition: et_fifo.c:544
int et_fifo_getBufIds(et_fifo_id id, int *bufIds)
This routine gets the array of ids assigned to buffers in each FIFO entry.
Definition: et_fifo.c:760
int et_fifo_getFillLevel(et_fifo_id id)
Definition: et_fifo.c:701
int et_fifo_getIdCount(et_fifo_id id)
This routine gets the number of buffers assigned an id in each FIFO entry.
Definition: et_fifo.c:743
int et_fifo_openConsumer(et_sys_id fid, et_fifo_id *fifoId)
Definition: et_fifo.c:339
size_t et_fifo_getBufSize(et_fifo_id fid)
This routine gets the max size of each buffer in bytes.
Definition: et_fifo.c:718
void et_fifo_setHasData(et_event *ev, int hasData)
This routine sets whether this ET event has data in it.
Definition: et_fifo.c:798
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 w...
Definition: et_fifo.c:421
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 FI...
Definition: et_fifo.c:639
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_f...
Definition: et_fifo.c:664
int et_fifo_hasData(et_event *ev)
This routine gets whether this ET event has data in it or not.
Definition: et_fifo.c:809
et_event * et_fifo_getBuf(int id, et_fifo_entry *entry)
Find the event/buffer in the fifo entry corresponding to the given id.
Definition: et_fifo.c:869
int et_fifo_getEntryCapacity(et_fifo_id fid)
This routine gets the max number of buffers in each FIFO entry.
Definition: et_fifo.c:730
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 f...
Definition: et_fifo.c:373
void et_fifo_freeEntry(et_fifo_entry *entry)
Routine to free a fifo entry created with et_fifo_entryCreate.
Definition: et_fifo.c:392
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 ...
Definition: et_fifo.c:830
This structure defines an Event which exists in shared memory, holds data, and gets passed from stati...
Definition: et.h:294
Structure to hold the context of a fifo connection to ET.
Definition: et_fifo.h:32
int entries
Total number of fifo entries in ET system.
Definition: et_fifo.h:35
int evCount
Number of buffers/events in ET system.
Definition: et_fifo.h:34
int producer
True if producing fifo entries, false if consuming fifo entries.
Definition: et_fifo.h:37
int capacity
Total number of buffer contained in this fifo element.
Definition: et_fifo.h:38
int idCount
Number of elements in bufIds array (if is producer).
Definition: et_fifo.h:43
et_sys_id openId
Id returned from et_open.
Definition: et_fifo.h:39
int userEntries
For consumers, max number of fifo entries in Users station (<= entries).
Definition: et_fifo.h:36
et_stat_id userStatId
User station id for both producers & consumers.
Definition: et_fifo.h:40
size_t evSize
Size in bytes of each ET buffer/event.
Definition: et_fifo.h:33
et_att_id attId
Attachment to GrandCentral Station for data producers User for data consumers.
Definition: et_fifo.h:41
int * bufIds
Array to hold ids - one for each buffer of a fifo entry (if is producer).
Definition: et_fifo.h:44
Structure to hold the a fifo entry obtained from ET.
Definition: et_fifo.h:49
et_fifo_id fid
fifo id used to get these events from ET.
Definition: et_fifo.h:51
et_event ** bufs
array of ET events.
Definition: et_fifo.h:50