mevb.c File Reference

Go to the source code of this file.

Functions

INT eb_mfragment_add (char *pdest, char *psrce, INT *size)
INT eb_begin_of_run (INT, char *, char *)
INT eb_end_of_run (INT, char *)
INT eb_user (INT, EBUILDER_CHANNEL *, EVENT_HEADER *, void *, INT *)
INT source_scan (INT fmt, INT nfragment, HNDLE dest_hBuf, char *dest_event)

Variables

EBUILDER_SETTINGS ebset


Function Documentation

INT eb_begin_of_run INT  rn,
char *  UserField,
char *  error
 

Hook to the event builder task at PreStart transition.

Parameters:
rn run number
UserField argument from /Ebuilder/Settings
error error string to be passed back to the system.
Returns:
EB_SUCCESS

Definition at line 55 of file ebuser.c.

INT eb_end_of_run INT  rn,
char *  error
 

Hook to the event builder task at completion of event collection after receiving the Stop transition.

Parameters:
rn run number
error error string to be passed back to the system.
Returns:
EB_SUCCESS

Definition at line 70 of file ebuser.c.

INT eb_mfragment_add char *  pdest,
char *  psrce,
INT *  size
 

Parameters:
pdest Destination pointer
psrce Fragment source pointer
size Current destination event size (byte)
Returns:
EB_SUCCESS

Definition at line 84 of file mevb.c.

Referenced by main().

INT eb_user INT  nfrag,
EBUILDER_CHANNEL *  ebch,
EVENT_HEADER pheader,
void *  pevent,
INT *  dest_size
 

Hook to the event builder task after the reception of all fragments of the same serial number. The destination event has already the final EVENT_HEADER setup with the data size set to 0. It is than possible to add private data at this point using the proper bank calls.

The ebch[] array structure points to nfragment channel structure with the following content:

typedef struct {
    char  name[32];         // Fragment name (Buffer name).
    DWORD serial;           // Serial fragment number.
    char *pfragment;        // Pointer to fragment (EVENT_HEADER *)
    ...
} EBUILDER_CHANNEL;

The correct code for including your own MIDAS bank is shown below where TID_xxx is one of the valid Bank type starting with TID_ for midas format or xxx_BKTYPE for Ybos data format. bank_name is a 4 character descriptor. pdata has to be declared accordingly with the bank type. Refers to the ebuser.c source code for further description.

It is not possible to mix within the same destination event different event format!

  // Event is empty, fill it with BANK_HEADER
  // If you need to add your own bank at this stage 
  
  bk_init(pevent);
  bk_create(pevent, bank_name, TID_xxxx, &pdata);
  *pdata++ = ...;
  *dest_size = bk_close(pevent, pdata);
  pheader->data_size = *dest_size + sizeof(EVENT_HEADER);

For YBOS format, use the following example.

  ybk_init(pevent);
  ybk_create(pevent, "EBBK", I4_BKTYPE, &pdata);
  *pdata++ = 0x12345678;
  *pdata++ = 0x87654321;
  *dest_size = ybk_close(pevent, pdata);
  *dest_size *= 4;
  pheader->data_size = *dest_size + sizeof(YBOS_BANK_HEADER);

Parameters:
nfrag Number of fragment.
ebch Structure to all the fragments.
pheader Destination pointer to the header.
pevent Destination pointer to the bank header.
dest_size Destination event size in bytes.
Returns:
EB_SUCCESS

Definition at line 137 of file ebuser.c.

Referenced by source_scan().

INT eb_yfragment_add char *  pdest,
char *  psrce,
INT *  size
 

Definition at line 141 of file mevb.c.

Referenced by main().

void free_event_buffer INT  nfrag  ) 
 

Definition at line 283 of file mevb.c.

Referenced by main(), source_booking(), and source_unbooking().

INT handFlush INT   ) 
 

Definition at line 296 of file mevb.c.

Referenced by main().

int main unsigned int  argc,
char **  argv
 

Definition at line 635 of file mevb.c.

INT source_booking INT  nfrag  ) 
 

Definition at line 329 of file mevb.c.

Referenced by tr_prestart().

INT source_scan INT  fmt,
INT  nfragment,
HNDLE  dest_hBuf,
char *  dest_event
 

Scan all the fragment source once per call.

  1. This will retrieve the full midas event not swapped (except the MIDAS_HEADER) for each fragment if possible. The fragment will be stored in the channel event pointer.
  2. if after a full nfrag path some frag are still not cellected, it returns with the frag# missing for timeout check.
  3. If ALL fragments are present it will check the midas serial# for a full match across all the fragments.
  4. If the serial check fails it returns with "event mismatch" and will abort the event builder but not stop the run for now.
  5. If the serial check is passed, it will call the user_build function where the destination event is going to be composed.

Parameters:
fmt Fragment format type
nfragment number of fragment to collect
dest_hBuf Destination buffer handle
dest_event destination point for built event
Returns:
EB_NO_MORE_EVENT, EB_COMPOSE_TIMEOUT if different then SUCCESS (bm_compose, rpc_sent error)

Definition at line 470 of file mevb.c.

Referenced by main().

INT source_unbooking nfrag   ) 
 

Definition at line 413 of file mevb.c.

Referenced by main().

INT tr_prestart INT  rn,
char *  error
 

Definition at line 216 of file mevb.c.

Referenced by main().

INT tr_stop INT  rn,
char *  error
 

Definition at line 270 of file mevb.c.

Referenced by main().

INT ybos_event_swap DWORD *  pevt  ) 
 

Referenced by eb_yfragment_add(), and source_scan().


Variable Documentation

BOOL abort_requested = FALSE stop_requested = TRUE
 

Definition at line 56 of file mevb.c.

Referenced by main(), source_scan(), and tr_prestart().

DWORD cdemask = 0
 

Definition at line 62 of file mevb.c.

Referenced by main(), source_scan(), and tr_prestart().

BOOL debug = FALSE debug1=FALSE
 

Definition at line 54 of file mevb.c.

EBUILDER_CHANNEL ebch[MAX_CHANNELS]
 

Definition at line 49 of file mevb.c.

Referenced by eb_user(), free_event_buffer(), handFlush(), main(), source_booking(), source_scan(), source_unbooking(), and tr_prestart().

EBUILDER_SETTINGS ebset
 

The Event builder main file.

file mevb.c

Definition at line 47 of file mevb.c.

Referenced by main(), source_booking(), source_scan(), and tr_prestart().

EBUILDER_STATISTICS ebstat
 

Definition at line 48 of file mevb.c.

Referenced by main(), source_scan(), and tr_prestart().

DWORD gbl_bytes_sent = 0 gbl_events_sent=0
 

Definition at line 61 of file mevb.c.

Referenced by main(), source_scan(), and tr_prestart().

INT gbl_run = 0
 

Definition at line 63 of file mevb.c.

Referenced by main(), and tr_prestart().

HNDLE hDB
 

Definition at line 53 of file mevb.c.

HNDLE hKey
 

Definition at line 53 of file mevb.c.

Referenced by cm_connect_client(), cm_delete_client_info(), cm_disconnect_experiment(), cm_exist(), cm_get_client_info(), cm_msg_log(), cm_msg_log1(), cm_msg_retrieve(), cm_register_deferred_transition(), cm_register_transition(), cm_set_client_info(), cm_set_watchdog_params(), cm_shutdown(), cm_transition(), db_check_record(), db_close_record(), db_copy(), db_create_key(), db_create_link(), db_create_record(), db_delete_key(), db_delete_key1(), db_enum_key(), db_find_key(), db_get_data(), db_get_data_index(), db_get_key(), db_get_key_info(), db_get_key_time(), db_get_record(), db_get_record_size(), db_open_record(), db_paste(), db_save(), db_save_struct(), db_set_data(), db_set_data_index(), db_set_record(), db_set_value(), db_update_record(), logger_root(), main(), and update_odb().

HNDLE hStatKey
 

Definition at line 53 of file mevb.c.

Referenced by main(), and tr_prestart().

DWORD max_event_size = MAX_EVENT_SIZE
 

Definition at line 51 of file mevb.c.

Referenced by handFlush(), main(), scheduler(), send_event(), source_booking(), and source_scan().

INT(* meb_fragment_add)(char *, char *, INT *)
 

Definition at line 65 of file mevb.c.

Referenced by main(), and source_scan().

INT run_state = 0
 

Definition at line 59 of file mevb.c.

DWORD start_time = 0 stop_time=0 request_stop_time=0
 

Definition at line 60 of file mevb.c.

Referenced by bm_check_buffers(), cm_shutdown(), main(), and tr_prestart().

BOOL stopped = TRUE
 

Definition at line 57 of file mevb.c.

Referenced by handFlush(), and tr_prestart().

BOOL wheel = FALSE
 

Definition at line 58 of file mevb.c.

Referenced by main(), and source_scan().


Midas DOC Version 1.9.3 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Suzannah Daviel - Doxygen - Peter Green - Greg Hackman - Gertjan Hofman - Paul Knowles - Rudi Meier - Glenn Moloney - Dave Morris - Konstantin Olchanski - Renee Poutissou - Andreas Suter - Piotr Adam Zolnierczuk