mevb.c File Reference

Go to the source code of this file.

Defines

#define SERVER_CACHE_SIZE   100000

Functions

INT source_scan (INT fmt, EQUIPMENT_INFO *eq_info)
INT eb_begin_of_run (INT, char *, char *)
INT eb_end_of_run (INT, char *)
INT eb_user (INT, BOOL mismatch, EBUILDER_CHANNEL *, EVENT_HEADER *, void *, INT *)


Define Documentation

#define DEFAULT_FE_TIMEOUT   60000

Definition at line 27 of file mevb.c.

#define EQUIPMENT_COMMON_STR   "\Event ID = WORD : 0\n\Trigger mask = WORD : 0\n\Buffer = STRING : [32] SYSTEM\n\Type = INT : 0\n\Source = INT : 0\n\Format = STRING : [8] FIXED\n\Enabled = BOOL : 0\n\Read on = INT : 0\n\Period = INT : 0\n\Event limit = DOUBLE : 0\n\Num subevents = DWORD : 0\n\Log history = INT : 0\n\Frontend host = STRING : [32] \n\Frontend name = STRING : [32] \n\Frontend file name = STRING : [256] \n\"

Definition at line 82 of file mevb.c.

#define EQUIPMENT_STATISTICS_STR   "\Events sent = DOUBLE : 0\n\Events per sec. = DOUBLE : 0\n\kBytes per sec. = DOUBLE : 0\n\"

Definition at line 100 of file mevb.c.

#define ODB_UPDATE_TIME   1000

Definition at line 25 of file mevb.c.

#define SERVER_CACHE_SIZE   100000

dox

Definition at line 23 of file mevb.c.


Function Documentation

INT close_buffers ( void   ) 

Definition at line 832 of file mevb.c.

Referenced by scan_fragment().

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 105 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 120 of file ebuser.c.

Referenced by close_buffers().

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

Definition at line 422 of file mevb.c.

Referenced by load_fragment().

INT eb_user ( INT  nfrag,
BOOL  mismatch,
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_size(pevent) + sizeof(EVENT_HEADER);
  pheader->data_size = bk_size(pevent);

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;
Parameters:
nfrag Number of fragment.
mismatch Midas Serial number mismatch flag.
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 188 of file ebuser.c.

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

Definition at line 478 of file mevb.c.

Referenced by load_fragment().

INT ebuilder_exit ( void   ) 

Definition at line 86 of file ebuser.c.

Referenced by main().

INT ebuilder_init ( void   ) 

Definition at line 80 of file ebuser.c.

Referenced by main().

INT ebuilder_loop ( void   ) 

Definition at line 92 of file ebuser.c.

void free_event_buffer ( INT  nfrag  ) 

Definition at line 680 of file mevb.c.

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

INT handFlush ( void   ) 

Definition at line 692 of file mevb.c.

Referenced by close_buffers().

INT load_fragment ( void   ) 

Definition at line 231 of file mevb.c.

Referenced by main().

int main ( int  argc,
char **  argv 
)

Definition at line 1040 of file mevb.c.

INT register_equipment ( void   ) 

Definition at line 107 of file mevb.c.

INT scan_fragment ( void   ) 

Definition at line 310 of file mevb.c.

Referenced by main().

INT source_booking ( void   ) 

Definition at line 726 of file mevb.c.

INT source_scan ( INT  fmt,
EQUIPMENT_INFO eq_info 
)

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
eq_info Equipement pointer
Returns:
EB_NO_MORE_EVENT, EB_COMPOSE_TIMEOUT if different then SUCCESS (bm_compose, rpc_sent error)

Definition at line 881 of file mevb.c.

Referenced by scan_fragment().

INT source_unbooking ( void   ) 

Definition at line 798 of file mevb.c.

Referenced by close_buffers(), and main().

INT tr_start ( INT  rn,
char *  error 
)

Definition at line 550 of file mevb.c.

INT tr_stop ( INT  rn,
char *  error 
)

Definition at line 667 of file mevb.c.

INT ybos_event_swap ( DWORD pevt  ) 

Referenced by eb_yfragment_add(), and source_scan().


Variable Documentation

BOOL abort_requested = FALSE

Definition at line 50 of file mevb.c.

Referenced by close_buffers(), and scan_fragment().

DWORD actual_millitime

Definition at line 36 of file mevb.c.

DWORD actual_time

Definition at line 35 of file mevb.c.

char bars[] = "|\\-/"

Definition at line 48 of file mevb.c.

Referenced by scan_fragment(), and v1729_TimeCalibrationRun().

char buffer_name[NAME_LENGTH]

Definition at line 41 of file mevb.c.

Referenced by load_fragment(), and main().

BOOL debug = FALSE

Definition at line 45 of file mevb.c.

BOOL debug1 = FALSE

Definition at line 45 of file mevb.c.

Referenced by handFlush(), and source_scan().

char* dest_event

Definition at line 43 of file mevb.c.

Referenced by load_fragment().

INT display_period

Definition at line 32 of file ebuser.c.

EBUILDER_CHANNEL ebch[MAX_CHANNELS]

Definition at line 30 of file mevb.c.

Referenced by free_event_buffer(), handFlush(), load_fragment(), main(), scan_fragment(), source_booking(), source_scan(), and source_unbooking().

EBUILDER_SETTINGS ebset

Definition at line 29 of file mevb.c.

Referenced by eb_user(), handFlush(), main(), source_booking(), source_scan(), and tr_start().

EQUIPMENT equipment[]

Definition at line 59 of file ebuser.c.

INT event_buffer_size

Definition at line 41 of file ebuser.c.

char expt_name[NAME_LENGTH]

Definition at line 40 of file mevb.c.

Referenced by main().

BOOL frontend_call_loop

Definition at line 36 of file frontend.c.

char* frontend_file_name

Definition at line 26 of file ebuser.c.

char* frontend_name

Definition at line 23 of file ebuser.c.

HNDLE hDB

Definition at line 44 of file mevb.c.

HNDLE hEqKey

Definition at line 44 of file mevb.c.

Referenced by load_fragment().

HNDLE hESetKey

Definition at line 44 of file mevb.c.

HNDLE hKey

Definition at line 44 of file mevb.c.

Referenced by analyzer_init(), cm_connect_client(), cm_delete_client_info(), cm_disconnect_experiment(), cm_get_client_info(), cm_msg_log(), cm_msg_log1(), cm_msg_retrieve(), cm_set_client_info(), cm_set_watchdog_params(), device_driver(), logger_root(), main(), register_equipment(), and tr_start().

char host_name[HOST_NAME_LENGTH]

Definition at line 39 of file mevb.c.

HNDLE hStatKey

Definition at line 44 of file mevb.c.

HNDLE hSubkey

Definition at line 44 of file mevb.c.

Referenced by cm_connect_client(), cm_exist(), cm_set_client_info(), cm_shutdown(), cm_transition(), and load_fragment().

int i_bar

Definition at line 49 of file mevb.c.

Referenced by scan_fragment(), and v1729_TimeCalibrationRun().

DWORD last_time

Definition at line 34 of file mevb.c.

Referenced by scan_fragment().

INT max_event_size

Definition at line 35 of file ebuser.c.

INT max_event_size_frag

Definition at line 38 of file ebuser.c.

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

Definition at line 53 of file mevb.c.

Referenced by load_fragment().

char mevb_svn_revision[] = "$Id: mevb.c 3659 2007-04-03 14:30:48Z ritt@PSI.CH $"

Definition at line 38 of file mevb.c.

Referenced by main().

INT nfragment

Definition at line 42 of file mevb.c.

Referenced by handFlush(), load_fragment(), scan_fragment(), source_booking(), source_scan(), source_unbooking(), and tr_start().

DWORD request_stop_time = 0

Definition at line 51 of file mevb.c.

Referenced by close_buffers(), and tr_stop().

INT run_number

Definition at line 33 of file mevb.c.

INT run_state

Definition at line 32 of file mevb.c.

BOOL stop_requested = TRUE

Definition at line 50 of file mevb.c.

Referenced by scan_fragment(), and tr_stop().

DWORD stop_time = 0

Definition at line 51 of file mevb.c.

Referenced by close_buffers().

BOOL wheel = FALSE

Definition at line 47 of file mevb.c.

Referenced by main(), and scan_fragment().


Midas DOC Version 2.0.2 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk