MIDAS
|
Classes | |
struct | BUFFER_INFO |
struct | EVENT_DEFRAG_BUFFER |
Macros | |
#define | MAX_DEFRAG_EVENTS 10 |
Variables | |
static DWORD | _bm_max_event_size = 0 |
static int | _bm_lock_timeout = 5 * 60 * 1000 |
static double | _bm_mutex_timeout_sec = _bm_lock_timeout/1000 + 15.000 |
static EVENT_DEFRAG_BUFFER | defrag_buffer [MAX_DEFRAG_EVENTS] |
dox dox
INT bm_add_event_request | ( | INT | buffer_handle, |
short int | event_id, | ||
short int | trigger_mask, | ||
INT | sampling_type, | ||
EVENT_HANDLER * | func, | ||
INT | request_id | ||
) |
dox
Definition at line 8314 of file midas.cxx.
Check if any requested event is waiting in a buffer
Definition at line 10954 of file midas.cxx.
|
static |
Definition at line 8966 of file midas.cxx.
Check all clients on buffer, remove invalid clients
Definition at line 6066 of file midas.cxx.
Definition at line 6408 of file midas.cxx.
Close all open buffers
Definition at line 7243 of file midas.cxx.
Closes an event buffer previously opened with bm_open_buffer().
buffer_handle | buffer handle |
Definition at line 7096 of file midas.cxx.
INT bm_compose_event | ( | EVENT_HEADER * | event_header, |
short int | event_id, | ||
short int | trigger_mask, | ||
DWORD | data_size, | ||
DWORD | serial | ||
) |
Compose a Midas event header. An event header can usually be set-up manually or through this routine. If the data size of the event is not known when the header is composed, it can be set later with event_header->data-size = <...> Following structure is created at the beginning of an event
event_header | pointer to the event header |
event_id | event ID of the event |
trigger_mask | trigger mask of the event |
data_size | size if the data part of the event in bytes |
serial | serial number |
Definition at line 8281 of file midas.cxx.
INT bm_compose_event_threadsafe | ( | EVENT_HEADER * | event_header, |
short int | event_id, | ||
short int | trigger_mask, | ||
DWORD | data_size, | ||
DWORD * | serial | ||
) |
Definition at line 8292 of file midas.cxx.
|
static |
Definition at line 9069 of file midas.cxx.
Deletes an event request previously done with bm_request_event(). When an event request gets deleted, events of that requested type are not received any more. When a buffer is closed via bm_close_buffer(), all event requests from that buffer are deleted automatically
request_id | request identifier given by bm_request_event() |
Definition at line 8584 of file midas.cxx.
|
static |
Definition at line 8823 of file midas.cxx.
Clears event buffer and cache. If an event buffer is large and a consumer is slow in analyzing events, events are usually received some time after they are produced. This effect is even more experienced if a read cache is used (via bm_set_cache_size()). When changes to the hardware are made in the experience, the consumer will then still analyze old events before any new event which reflects the hardware change. Users can be fooled by looking at histograms which reflect the hardware change many seconds after they have been made.
To overcome this potential problem, the analyzer can call bm_empty_buffers() just after the hardware change has been made which skips all old events contained in event buffers and read caches. Technically this is done by forwarding the read pointer of the client. No events are really deleted, they are still visible to other clients like the logger.
Note that the front-end also contains write buffers which can delay the delivery of events. The standard front-end framework mfe.c reduces this effect by flushing all buffers once every second.
Definition at line 11240 of file midas.cxx.
|
static |
Definition at line 8992 of file midas.cxx.
|
static |
Definition at line 10207 of file midas.cxx.
|
static |
Empty write cache. This function should be used if events in the write cache should be visible to the consumers immediately. It should be called at the end of each run, otherwise events could be kept in the write buffer and will flow to the data of the next run.
buffer_handle | Buffer handle obtained via bm_open_buffer() or 0 to flush data in the mserver event socket |
timeout_msec | Timeout waiting for free space in the event buffer. If BM_WAIT, wait forever. If BM_NO_WAIT, the function returns immediately with a value of BM_ASYNC_RETURN without writing the cache. |
Definition at line 10063 of file midas.cxx.
Definition at line 9987 of file midas.cxx.
If buffer is already open, return it's handle
buffer_name | buffer name |
Definition at line 7075 of file midas.cxx.
Definition at line 6223 of file midas.cxx.
Check if an event matches a given event request by the event id and trigger mask
event_id | Event ID of request |
trigger_mask | Trigger mask of request |
pevent | Pointer to event to check |
Definition at line 6015 of file midas.cxx.
|
static |
Definition at line 6256 of file midas.cxx.
|
static |
Definition at line 9603 of file midas.cxx.
Open an event buffer. Two default buffers are created by the system. The "SYSTEM" buffer is used to exchange events and the "SYSMSG" buffer is used to exchange system messages. The name and size of the event buffers is defined in midas.h as EVENT_BUFFER_NAME and DEFAULT_BUFFER_SIZE. Following example opens the "SYSTEM" buffer, requests events with ID 1 and enters a main loop. Events are then received in process_event()
buffer_name | Name of buffer |
buffer_size | Default size of buffer in bytes. Can by overwritten with ODB value |
buffer_handle | Buffer handle returned by function |
Definition at line 6717 of file midas.cxx.
|
static |
Definition at line 8891 of file midas.cxx.
|
static |
Definition at line 8865 of file midas.cxx.
Definition at line 11126 of file midas.cxx.
Check a buffer if an event is available and call the dispatch function if found.
buffer_name | Name of buffer |
Definition at line 10902 of file midas.cxx.
|
static |
Definition at line 10264 of file midas.cxx.
|
static |
|
static |
Receives events directly. This function is an alternative way to receive events without a main loop.
It can be used in analysis systems which actively receive events, rather than using callbacks. A analysis package could for example contain its own command line interface. A command like "receive 1000 events" could make it necessary to call bm_receive_event() 1000 times in a row to receive these events and then return back to the command line prompt. The according bm_request_event() call contains NULL as the callback routine to indicate that bm_receive_event() is called to receive events.
buffer_handle | buffer handle |
destination | destination address where event is written to |
buf_size | size of destination buffer on input, size of event plus header on return. |
timeout_msec | Wait so many millisecond for new data. Special values: BM_WAIT: wait forever, BM_NO_WAIT: do not wait, return BM_ASYNC_RETURN if no data is immediately available |
Definition at line 10650 of file midas.cxx.
INT bm_receive_event_alloc | ( | INT | buffer_handle, |
EVENT_HEADER ** | ppevent, | ||
int | timeout_msec | ||
) |
Receives events directly. This function is an alternative way to receive events without a main loop.
It can be used in analysis systems which actively receive events, rather than using callbacks. A analysis package could for example contain its own command line interface. A command like "receive 1000 events" could make it necessary to call bm_receive_event() 1000 times in a row to receive these events and then return back to the command line prompt. The according bm_request_event() call contains NULL as the callback routine to indicate that bm_receive_event() is called to receive events.
buffer_handle | buffer handle |
ppevent | pointer to the received event pointer, event pointer should be free()ed to avoid memory leak |
timeout_msec | Wait so many millisecond for new data. Special values: BM_WAIT: wait forever, BM_NO_WAIT: do not wait, return BM_ASYNC_RETURN if no data is immediately available |
Definition at line 10731 of file midas.cxx.
|
static |
Definition at line 10483 of file midas.cxx.
Receives events directly. This function is an alternative way to receive events without a main loop.
It can be used in analysis systems which actively receive events, rather than using callbacks. A analysis package could for example contain its own command line interface. A command like "receive 1000 events" could make it necessary to call bm_receive_event() 1000 times in a row to receive these events and then return back to the command line prompt. The according bm_request_event() call contains NULL as the callback routine to indicate that bm_receive_event() is called to receive events.
buffer_handle | buffer handle |
ppevent | pointer to the received event pointer, event pointer should be free()ed to avoid memory leak |
timeout_msec | Wait so many millisecond for new data. Special values: BM_WAIT: wait forever, BM_NO_WAIT: do not wait, return BM_ASYNC_RETURN if no data is immediately available |
Definition at line 10809 of file midas.cxx.
void bm_remove_client_locked | ( | BUFFER_HEADER * | pheader, |
int | j | ||
) |
Called to forcibly disconnect given client from a data buffer
Definition at line 6035 of file midas.cxx.
Delete a previously placed request for a specific event type in the client structure of the buffer refereced by buffer_handle.
buffer_handle | Handle to the buffer where the re- quest should be placed in |
request_id | Request id returned by bm_request_event |
Definition at line 8518 of file midas.cxx.
INT bm_request_event | ( | HNDLE | buffer_handle, |
short int | event_id, | ||
short int | trigger_mask, | ||
INT | sampling_type, | ||
HNDLE * | request_id, | ||
EVENT_HANDLER * | func | ||
) |
dox Place an event request based on certain characteristics. Multiple event requests can be placed for each buffer, which are later identified by their request ID. They can contain different callback routines. Example see bm_open_buffer() and bm_receive_event()
buffer_handle | buffer handle obtained via bm_open_buffer() |
event_id | event ID for requested events. Use EVENTID_ALL to receive events with any ID. |
trigger_mask | trigger mask for requested events. The requested events must have at least one bit in its trigger mask common with the requested trigger mask. Use TRIGGER_ALL to receive events with any trigger mask. |
sampling_type | specifies how many events to receive. A value of GET_ALL receives all events which match the specified event ID and trigger mask. If the events are consumed slower than produced, the producer is automatically slowed down. A value of GET_NONBLOCKING receives as much events as possible without slowing down the producer. GET_ALL is typically used by the logger, while GET_NONBLOCKING is typically used by analyzers. |
request_id | request ID returned by the function. This ID is passed to the callback routine and must be used in the bm_delete_request() routine. |
func | allback routine which gets called when an event of the specified type is received. |
Definition at line 8465 of file midas.cxx.
Definition at line 6391 of file midas.cxx.
Definition at line 9678 of file midas.cxx.
int bm_send_event_sg | ( | int | buffer_handle, |
int | sg_n, | ||
const char *const | sg_ptr[], | ||
const size_t | sg_len[], | ||
int | timeout_msec | ||
) |
Sends an event to a buffer. This function check if the buffer has enough space for the event, then copies the event to the buffer in shared memory. If clients have requests for the event, they are notified via an UDP packet.
buffer_handle | Buffer handle obtained via bm_open_buffer() |
source | Address of event buffer |
buf_size | Size of event including event header in bytes |
timeout_msec | Timeout waiting for free space in the event buffer. If BM_WAIT, wait forever. If BM_NO_WAIT, the function returns immediately with a value of BM_ASYNC_RETURN without writing the event to the buffer |
Definition at line 9778 of file midas.cxx.
int bm_send_event_vec | ( | int | buffer_handle, |
const std::vector< std::vector< char > > & | event, | ||
int | timeout_msec | ||
) |
Modifies buffer cache size. Without a buffer cache, events are copied to/from the shared memory event by event.
To protect processed from accessing the shared memory simultaneously, semaphores are used. Since semaphore operations are CPU consuming (typically 50-100us) this can slow down the data transfer especially for small events. By using a cache the number of semaphore operations is reduced dramatically. Instead writing directly to the shared memory, the events are copied to a local cache buffer. When this buffer is full, it is copied to the shared memory in one operation. The same technique can be used when receiving events.
The drawback of this method is that the events have to be copied twice, once to the cache and once from the cache to the shared memory. Therefore it can happen that the usage of a cache even slows down data throughput on a given environment (computer type, OS type, event size). The cache size has therefore be optimized manually to maximize data throughput.
buffer_handle | buffer handle obtained via bm_open_buffer() |
read_size | cache size for reading events in bytes, zero for no cache |
write_size | cache size for writing events in bytes, zero for no cache |
Definition at line 8140 of file midas.cxx.
Definition at line 10833 of file midas.cxx.
Skip all events in current buffer.
Useful for single event displays to see the newest events
buffer_handle | Handle of the buffer. Must be obtained via bm_open_buffer. |
Definition at line 10874 of file midas.cxx.
Update last activity time
Definition at line 6117 of file midas.cxx.
|
static |
Definition at line 8720 of file midas.cxx.
Definition at line 6307 of file midas.cxx.
|
static |
Definition at line 5922 of file midas.cxx.
|
static |
Definition at line 8622 of file midas.cxx.
Definition at line 6189 of file midas.cxx.
|
static |
Definition at line 9080 of file midas.cxx.
|
static |
Definition at line 9392 of file midas.cxx.
|
static |
Definition at line 8787 of file midas.cxx.
Definition at line 6586 of file midas.cxx.
|
static |
Definition at line 6464 of file midas.cxx.
Close all open buffers
Definition at line 7280 of file midas.cxx.
|
static |
Definition at line 9504 of file midas.cxx.
|
static |
|
static |