33 #define CAENV767_MAX_DMA_SIZE 256
34 #define CAENV767_MAX_SIZE (32*1024*4)
35 #define ACTIVE_READOUT_MAX_PER_POLL (2*1024)
36 #define CAENV767_NUM_CHANNELS 128
55 #define MAX_CAENV767 4
59 #define CAENV767_OUTBUF 0x00
60 #define CAENV767_CTR1 0x10
61 #define CAENV767_STR2 0x48
62 #define CAENV767_EVT_COUNT 0x4C
63 #define CAENV767_OPHAND 0x50
64 #define CAENV767_OPCODE 0x52
65 #define CAENV767_CLEAR 0x54
68 #define CAENV767_NOT_VALID 0x00600000
71 #define CAENV767_GLOBAL_TDC_ERROR 0x0008
128 odb_get_bool(
"/Equipment/Crate %d/Settings/%s/Active Readout mode",
133 odb_get_bool(
"/Equipment/Crate %d/Settings/%s/Record trailing edges",
141 odb_get_int(
"/Equipment/Crate %d/Settings/%s/Half-full level",
144 odb_get_int(
"/Equipment/Crate %d/Settings/%s/Active readout buffer size",
172 "/Equipment/Crate %d/Settings/%s/channels/channel enabled",
176 channelstatus = channel_enable_array[
channel];
177 if (channelstatus == 0) {
206 diag_print(1,
"ODB says CAEN %d is present, ", j);
208 odb_get_bool(
"/Equipment/Crate %d/Settings/CAEN %d/enabled status",
211 diag_print(1,
"and is enabled. Initializing...\n");
260 int max_size,
bool in_active_readout)
262 if(!in_active_readout) {
271 for(
int i = 0;
i < max_size /
sizeof(
DWORD);
i++) {
279 *((
DWORD *) buffer) = word;
280 buffer +=
sizeof(
DWORD);
281 size +=
sizeof(
DWORD);
304 gettimeofday(&now, NULL);
314 size =
MIN(size, expected_words);
328 diag_print(0,
"Status from caenV767_fifo_read is %d for %s\n", status,
378 bk_create(pevent, caen->
bank_name, TID_DWORD, &pdata);
402 for(
int tdc = 0; tdc < 4; tdc++) {
403 short ind_tdc_error_mask = (1 << (12+tdc));
404 if(str2 & (1 << (12+tdc))) {
405 flag_word |= (1 << tdc);
409 pdata[(active_size + final_size)/
sizeof(
DWORD)] = flag_word;
410 final_size +=
sizeof(
DWORD);
418 int total_size = active_size + final_size;
419 if ( total_size > 500000 ) {
420 printf(
"ERROR! Event size is too big (%i). The event will be rejected\n");
421 bk_close(pevent, pdata + 0);
423 bk_close(pevent, pdata + (active_size + final_size)/
sizeof(
DWORD));
437 gettimeofday(&now, NULL);