#include #include #include // #include #include #include //#include "conf_utils.h" #if 0 int main(){ // char* roc_name = "roccdc2"; // char* filename = "/home/somov/conf/conf_examp.cnf"; int rc; strcpy(filename, "/home/somov/conf/conf_examp.cnf"); strcpy(roc_name, "roctof2"); memset(fa250, 0, sizeof(fa250)); memset(fa125, 0, sizeof(fa125)); memset(&ti_bd, 0, sizeof(ti_bd)); memset(&dsc, 0, sizeof(dsc)); memset(&caen1290, 0, sizeof(caen1290)); rc = read_conf_global(filename,roc_name); if(rc != 0) return 0; rc = read_conf_common(roc_name); if(rc == 0) read_conf_user(roc_name); // print_fadc250_conf(3); // print_fadc250_conf(4); // print_ti_conf(); // printf(" Board type for crate %s = %s \n", roc_name, get_board_type_name("rocbcal8")); // FADC250_CONF fa250_test; // fa250_test = get_conf_fadc250(3); // printf(" get_conf_fadc250: group = %d, Serial number %s \n", fa250_test.group, fa250_test.SerNum); // FADC125_CONF fa125_test; // fa125_test = get_conf_fadc125(3); // printf(" get_conf_fadc125: group = %d, Serial number %s \n", fa125_test.group, fa125_test.SerNum); print_fadc125_conf(3); print_fadc125_conf(4); print_ts_conf(); print_ti_conf(); print_le_conf(); print_caen1290_conf(); return 0; } #endif FADC125_CONF get_conf_fadc125(int slot){ FADC125_CONF fa125_tmp; fa125_tmp = fa125[slot]; return fa125_tmp; } FADC250_CONF get_conf_fadc250(int slot){ FADC250_CONF fa250_tmp; fa250_tmp = fa250[slot]; return fa250_tmp; } det_type get_det_type(char* crate){ det_type det; if(strncmp(crate, "rocfcal", 7) == 0) det = fcal; if(strncmp(crate, "rocbcal", 7) == 0) det = bcal; if(strncmp(crate, "roccdc", 6) == 0) det = cdc; if(strncmp(crate, "roctof", 6) == 0) det = tof; if(strncmp(crate, "roctrig3", 8) == 0) det = trigger; return det; } bd_type get_board_type(char* crate){ bd_type board; /* FCAL */ if(strncmp(crate, "rocfcal", 7) == 0) board = fadc250; /* BCAL */ if( strncmp(crate, "rocbcal3", 8) == 0 || strncmp(crate, "rocbcal6", 8) == 0 || strncmp(crate, "rocbcal9", 8) == 0 || strncmp(crate, "rocbcal12", 9) == 0 ) board = f1tdc; else if( strncmp(crate, "rocbcal13", 9) == 0 || strncmp(crate, "rocbcal14", 9) == 0 || strncmp(crate, "rocbcal15", 9) == 0 || strncmp(crate, "rocbcal16", 9) == 0 ) board = dsc2; else if(strncmp(crate, "rocbcal", 7) == 0 ) board = fadc250; /* CDC */ if(strncmp(crate, "roccdc", 6) == 0) board = fadc125; /* TOF */ if(strncmp(crate, "roctof1", 7) == 0) board = fadc250; if(strncmp(crate, "roctof2", 7) == 0) board = tdc1290; if(strncmp(crate, "roctof3", 7) == 0) board = dsc2; /* Secondary Trigger Supervisor */ if(strncmp(crate, "roctrig3", 8) == 0) board = tss; return board; } char *get_board_type_name(char* crate){ char *bd_type; if(strncmp(crate, "rocfcal", 7) == 0) bd_type = "fadc250"; if( strncmp(crate, "rocbcal3", 8) == 0 || strncmp(crate, "rocbcal6", 8) == 0 || strncmp(crate, "rocbcal9", 8) == 0 || strncmp(crate, "rocbcal12", 9) == 0 ) bd_type = "f1tdc"; else if( strncmp(crate, "rocbcal13", 9) == 0 || strncmp(crate, "rocbcal14", 9) == 0 || strncmp(crate, "rocbcal15", 9) == 0 || strncmp(crate, "rocbcal16", 9) == 0 ) bd_type = "dsc2"; else if(strncmp(crate, "rocbcal", 7) == 0 ) bd_type = "fadc250"; if(strncmp(crate, "roccdc", 6) == 0) bd_type = "fadc125"; if(strncmp(crate, "roctof1", 7) == 0) bd_type = "fadc250"; if(strncmp(crate, "roctof2", 7) == 0) bd_type = "tdc1290"; if(strncmp(crate, "roctof3", 7) == 0) bd_type = "dsc2"; if(strncmp(crate, "roctrig3", 6) == 0) bd_type = "tss"; return bd_type; } int read_conf_global(char *filename, char *crate){ int debug = 0; FILE *pFile; int ch; int ii = 0, jj; int val; int args_assigned = -1, args = -1; char str_tmp[STRLEN]; char keyword[ROCLEN]; char str[STRLEN]; char str_val[80]; int msk[16]; int soft_trig[4]; int ti_fiber[8]; int ti_master_trig = 0; int ti_master = 0; int fiber_latency = 0; int i1 = 0, i2 = 0; memset(soft_trig,0,sizeof(soft_trig)); memset(ti_fiber,0,sizeof(ti_fiber)); det_type det_comp = det_unknown; det_type crate_det = get_det_type(crate); if(crate_det == det_unknown) { printf(BOLDRED "\n FATAL: Read_conf_global: Unknown detector type for crate %s \n" RESET, crate); return(-2); } bd_type crate_board = get_board_type(crate); if(crate_board == bd_unknown) { printf(BOLDRED "\n FATAL: Read_conf_global: Unknown board type for crate %s \n" RESET, crate); return(-2); } /* Open Global Configuration File */ pFile = fopen(filename, "r"); if(pFile == NULL) { printf(BOLDRED "\n FATAL: Read_conf_global: Cannot open config file %s \n" RESET, filename); return(-2); } printf(BOLDBLUE "\n Reading Global Configuration File %s \n" RESET, filename); printf(BOLDBLUE " Crate = %s, Board Type = %d, Detector = %d \n" RESET, crate, crate_board, crate_det); while ((ch = getc(pFile)) != EOF) { if ( ch == '#' || ch == '#' || ch == '=' ) { while (getc(pFile) != '\n') {} } else if( ch == '\n' ) {} else { ungetc(ch,pFile); if(fgets(str_tmp, sizeof(str_tmp), pFile)){ if(debug) printf(" %s \n",str_tmp); args_assigned = sscanf(str_tmp,"%s",str); if(debug) printf("args assigned %d \n", args_assigned); /* Read configuration for sub-detectors */ if(args_assigned == 1){ if(strncmp(str, "TRIGGER", 7) == 0){ printf(" TRIGGER config found \n"); det_comp = trigger; } if(strncmp(str, "FCAL", 4) == 0){ printf(" FCAL config found \n"); det_comp = fcal; } if(strncmp(str, "BCAL", 4) == 0){ printf(" BCAL config found \n"); det_comp = bcal; } if(strncmp(str, "CDC", 3) == 0){ printf(" CDC config found \n"); det_comp = cdc; } if(strncmp(str, "TOF", 3) == 0){ printf(" TOF config found \n"); det_comp = tof; } } /* ========== Trigger Settings ========== */ if(det_comp == trigger){ sscanf (str_tmp, "%s %s", keyword, str); if(strcmp("TS_MASTER_TRIG",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ts_bd.ts_master_trig); } if(strcmp("BLOCKLEVEL",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ts_bd.blocklevel); } if(strcmp("BUFFERLEVEL",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ts_bd.bufferlevel); } SCAN_SOFT_TRIG("TS_SOFT_TRIG",ts_bd.ts_soft_trig); SCAN_TD_SLOTS("TS_TD_SLOTS",ts_bd.ts_td_slots); SCAN_FP_INPUTS("TS_FP_INPUTS",ts_bd.ts_fp_inputs); if(strcmp("TI_MASTER_TRIG",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ti_master_trig); ti_bd.ti_master_trig = ti_master_trig; } if(strcmp("TI_MASTER",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ti_master); ti_bd.ti_master = ti_master; } SCAN_SOFT_TRIG("TI_SOFT_TRIG",ti_bd.ti_soft_trig); SCAN_FP_INPUTS("TI_FP_INPUTS",ti_bd.ti_fp_inputs); SCAN_TI_FIBER("TI_FIBER_EN",ti_bd.ti_fiber_en); if(strcmp("TI_FIBER_LATENCY_OFFSET",keyword) == 0){ sscanf (str_tmp, "%*s %x", &fiber_latency); ti_bd.fiber_latency = fiber_latency; } } /* ========== FCAL, BCAL, TOF FADC250 ========== */ if( ((det_comp == fcal) && (crate_board == fadc250) && (crate_det == fcal)) || ((det_comp == bcal) && (crate_board == fadc250) && (crate_det == bcal)) || ((det_comp == tof) && (crate_board == fadc250) && (crate_det == tof)) ){ sscanf (str_tmp, "%s %s", keyword, str); SCAN_B_SETS("FADC250_MODE", fa250[jj].mode); SCAN_B_SETS("FADC250_W_OFFSET", fa250[jj].winOffset); SCAN_B_SETS("FADC250_W_WIDTH", fa250[jj].winWidth); SCAN_B_SETS("FADC250_NSB", fa250[jj].nsb); SCAN_B_SETS("FADC250_NSA", fa250[jj].nsa); SCAN_B_SETS("FADC250_NPEAK", fa250[jj].npeak); SCAN_B_SETS("FADC250_TRIG_THR", fa250[jj].trig_thr); SCAN_B_SETS("FADC250_TRIG_NSB", fa250[jj].trig_nsb); SCAN_B_SETS("FADC250_TRIG_NSA", fa250[jj].trig_nsa); SCAN_B_XSETS("FADC250_F_REV", fa250[jj].f_rev); SCAN_B_XSETS("FADC250_B_REV", fa250[jj].b_rev); SCAN_B_XSETS("FADC250_TYPE", fa250[jj].b_ID); SCAN_TDP("FADC250_TRIG_BL",fa250[jj].trig_bl); SCAN_TDP("FADC250_READ_THR",fa250[jj].read_thr); SCAN_B_SSETS("FADC250_COM_DIR", fa250[jj].conf_common_dir); SCAN_B_SSETS("FADC250_COM_VER", fa250[jj].conf_common_ver); SCAN_B_SSETS("FADC250_USER_DIR", fa250[jj].conf_user_dir); SCAN_B_SSETS("FADC250_USER_VER", fa250[jj].conf_user_ver); } // FCAL and BCAL FADC250 /* ========== CDC ========== */ if( (det_comp == cdc) && (crate_board == fadc125) && (crate_det == cdc) ){ sscanf (str_tmp, "%s %s", keyword, str); SCAN_B_SETS("FADC125_MODE", fa125[jj].mode); SCAN_B_SETS("FADC125_W_OFFSET", fa125[jj].winOffset); SCAN_B_SETS("FADC125_W_WIDTH", fa125[jj].winWidth); SCAN_B_SETS("FADC125_NSB", fa125[jj].nsb); SCAN_B_SETS("FADC125_NSA", fa125[jj].nsa); SCAN_B_SETS("FADC125_NPEAK", fa125[jj].npeak); SCAN_B_XSETS("FADC125_F_REV", fa125[jj].f_rev); SCAN_B_XSETS("FADC125_B_REV", fa125[jj].b_rev); SCAN_B_XSETS("FADC125_P_REV", fa125[jj].p_rev); SCAN_B_XSETS("FADC125_TYPE", fa125[jj].b_ID); SCAN_TDP_125("FADC125_THR",fa125[jj].read_thr); SCAN_TDP_125("FADC125_DAC",fa125[jj].dac); SCAN_B_SSETS("FADC125_COM_DIR", fa125[jj].conf_common_dir); SCAN_B_SSETS("FADC125_COM_VER", fa125[jj].conf_common_ver); SCAN_B_SSETS("FADC125_USER_DIR", fa125[jj].conf_user_dir); SCAN_B_SSETS("FADC125_USER_VER", fa125[jj].conf_user_ver); } // CDC /* ========== TOF DSC2 ========== */ if( (det_comp == tof) && (crate_board == dsc2) && (crate_det == tof) ){ sscanf (str_tmp, "%s %s", keyword, str); if(strcmp(keyword,"DSC2_THRESHOLD") == 0){ sscanf (str_tmp, "%*s %d %d", &i1, &i2); for(ii = 0; ii < NBD_DSC2; ii++) for(jj = 0; jj < MAX_DSC2_CH; jj++){ dsc[ii].TDCThreshold[jj] = i1; dsc[ii].TRGThreshold[jj] = i2; } } if(strcmp(keyword,"DSC2_WIDTH") == 0) { sscanf (str_tmp, "%*s %d %d", &i1, &i2); for(ii = 0; ii < NBD_DSC2; ii++){ dsc[ii].TDCWidth = i1; dsc[ii].TRGWidth = i2; } } } // TOF DSC2 /* ========== TOF CAEN1290 TDC ========== */ if( (det_comp == tof) && (crate_board == tdc1290) && (crate_det == tof) ){ sscanf (str_tmp, "%s %s", keyword, str); SCAN_B_SETS("TDC1290_W_WIDTH", caen1290[jj].window_width); SCAN_B_SETS("TDC1290_W_OFFSET", caen1290[jj].window_offset); SCAN_B_SETS("TDC1290_W_EXTRA", caen1290[jj].window_extra); SCAN_B_SETS("TDC1290_W_REJECT", caen1290[jj].window_reject); SCAN_B_SETS("TDC1290_BLT_EVENTS", caen1290[jj].blt_Events); SCAN_B_SETS("TDC1290_N_HITS", caen1290[jj].n_Hits); SCAN_B_SETS("TDC1290_ALMOSTFULL", caen1290[jj].almostFullLevel); SCAN_B_SETS("TDC1290_OUT_PROG", caen1290[jj].outProgControl); SCAN_B_SETS("TDC1290_A24_A32", caen1290[jj].a24_a32); SCAN_B_SETS("TDC1290_SNGL_BLT", caen1290[jj].sngl_blt_mblt); SCAN_B_SETS("TDC1290_SST_RATE", caen1290[jj].sst_rate); SCAN_B_SETS("TDC1290_BERR_FIFO", caen1290[jj].berr_fifo); SCAN_B_SETS("TDC1290_EDGE", caen1290[jj].edge); } // TOF CAEN1290 TDC } } } fclose(pFile); return 0; } int read_conf_common(char *crate){ int debug = 0; FILE *pFile; int ch; int ii = 0, jj; int val; int args, msk[16], msk1[18]; int slot = -1; int first = -1, last = -1; char sn[NBD_FADC250][12]; char str[STRLEN], str2[STRLEN], str_tmp[STRLEN]; char keyword[ROCLEN]; int line = 0; det_type crate_det = get_det_type(crate ); if(crate_det == det_unknown) { printf(BOLDRED "\n FATAL: Read_conf_common: Unknown detector type for crate %s \n" RESET, crate); return(-2); } bd_type crate_board = get_board_type(crate ); if(crate_board == bd_unknown) { printf(BOLDRED "\n FATAL: Read_conf_common: Unknown board type for crate %s \n" RESET, crate); return(-2); } /* Take user configuration file name from the flobal config file */ char myfile[STRLEN]="";; switch(crate_board){ case fadc250: if(debug){ printf(" STRING LENGTH = %d %s \n", strlen(fa250[3].conf_common_dir), fa250[3].conf_common_dir); printf(" STRING LENGTH = %d %s \n", strlen(fa250[3].conf_common_ver), fa250[3].conf_common_ver); } if((strlen(fa250[3].conf_common_dir) != 0) && (strlen(fa250[3].conf_common_ver) != 0) ) sprintf(myfile,"%s/%s_fadc250_%s.cnf", fa250[3].conf_common_dir,crate,fa250[3].conf_common_ver); else { printf(BOLDRED "\n FATAL: Have to set FADC250_COM_DIR and FADC250_COM_VER in the global configuration file %s %s \n" RESET, fa250[3].conf_common_dir, fa250[3].conf_common_ver ); return(-2); } break; case fadc125: if(debug){ printf(" STRING LENGTH = %d %s \n", strlen(fa125[3].conf_common_dir), fa125[3].conf_common_dir); printf(" STRING LENGTH = %d %s \n", strlen(fa125[3].conf_common_ver), fa125[3].conf_common_ver); } if((strlen(fa125[3].conf_common_dir) != 0) && (strlen(fa125[3].conf_common_ver) != 0) ) sprintf(myfile,"%s/%s_fadc125_%s.cnf", fa125[3].conf_common_dir,crate,fa125[3].conf_common_ver); else { printf(BOLDRED "\n FATAL: Have to set FADC125_COM_DIR and FADC125_COM_VER in the global configuration file %s %s \n" RESET, fa125[3].conf_common_dir, fa125[3].conf_common_ver ); return(-2); } break; case tdc1290: return(0); break; case dsc2: return(0); break; default: break; } /* Open Global Configuration File */ pFile = fopen(myfile, "r"); if(pFile == NULL) { printf(BOLDRED "\n FATAL: Read_conf_common: Cannot open config file %s \n" RESET, myfile); return(-2); } printf(BOLDBLUE "\n Reading Common Parameters from %s \n" RESET, myfile); while ((ch = getc(pFile)) != EOF) { if(debug) printf(" %d %d %d \n",ch,' ','='); if ( ch == '#' || ch == '#' || ch == '=' ) { while (getc(pFile) != '\n') {} } else if( ch == '\n' ) {} else { ungetc(ch,pFile); if(fgets(str_tmp, sizeof(str_tmp), pFile)){ switch(crate_board){ case fadc250: sscanf (str_tmp, "%s %s", keyword, str); if(strcmp(keyword,"CRATE") == 0){ if(strcmp(crate, str) != 0){ printf(BOLDRED "\nRead_config_common: Wrong crate name in config file, %s\n" RESET, str); return(-2); } } SCAN_TDP("FADC250_DAC",fa250[jj].dac); SCAN_SLOT("FADC250_SLOTS",fa250[slot].group); if( (slot >= 3) && (slot != 11) && (slot != 12) && (slot < 21)){ SCAN_TDP("FADC250_DAC",fa250[slot].dac); SCAN_TDP_ALLCH("FADC250_ALLCH_DAC",fa250[slot].dac); } if(strcmp(keyword,"FADC250_ALLSN") == 0) { args = sscanf (str_tmp, "%*s %s %s %s %s %s %s %s %s %s %s \ %s %s %s %s %s %s %s %s %s %s %s", &sn[ 1][0], &sn[ 2][0], &sn[ 3][0], &sn[ 4][0], &sn[ 5][0], &sn[ 6][0], &sn[ 7][0], &sn[ 8][0], &sn[ 9][0], &sn[10][0], &sn[11][0], &sn[12][0], &sn[13][0], &sn[14][0], &sn[15][0], &sn[16][0], &sn[17][0], &sn[18][0], &sn[19][0], &sn[20][0], &sn[21][0]); if(args != 21) { printf(BOLDRED "\n Read_conf_common: Wrong number of SNs = %d, should be 21 \n\n" RESET, args); printf(" Read string: %s \n",str_tmp); return(-2); } for(ii = 1; ii < NBD_FADC250; ii++) sprintf((char *)fa250[ii].SerNum, "%s", sn[ii]); } break; case fadc125: sscanf (str_tmp, "%s %s", keyword, str); if(strcmp(keyword,"CRATE") == 0){ if(strcmp(crate, str) != 0){ printf(BOLDRED "\nRead_config_common: Wrong crate name in config file, %s\n" RESET, str); return(-2); } } if(strcmp(keyword,"FADC125_ALLSN") == 0) { args = sscanf (str_tmp, "%*s %s %s %s %s %s %s %s %s %s %s \ %s %s %s %s %s %s %s %s %s %s %s", &sn[ 1][0], &sn[ 2][0], &sn[ 3][0], &sn[ 4][0], &sn[ 5][0], &sn[ 6][0], &sn[ 7][0], &sn[ 8][0], &sn[ 9][0], &sn[10][0], &sn[11][0], &sn[12][0], &sn[13][0], &sn[14][0], &sn[15][0], &sn[16][0], &sn[17][0], &sn[18][0], &sn[19][0], &sn[20][0], &sn[21][0]); if(args != 21) { printf("\n Read_conf_common: Wrong number of SNs %d, should be 21 :: %s\n\n",args,str_tmp); return(-5); } for(ii = 1; ii < NBD_FADC125; ii++) sprintf((char *)fa125[ii].SerNum, "%s", sn[ii]); } SCAN_SLOT("FADC125_SLOTS", fa125[slot].group); SCAN_FA125_DAC_THR("FADC125_DAC_CH_", fa125[slot].dac); SCAN_TDP_125("FADC125_DAC",fa125[slot].dac); SCAN_FA125_DAC_THR("FADC125_THR_CH_", fa125[slot].read_thr); SCAN_TDP_125("FADC125_THR",fa125[slot].read_thr); break; default: printf(BOLDRED "read_conf_common: Unknown board type %d. Exit" RESET, crate_board); return(-3); break; } } } } fclose(pFile); return 0; } int read_conf_user(char *crate){ int debug = 0; FILE *pFile; int ch; int jj; int args, msk[16], msk1[18]; int slot = -1; int first = -1, last = -1; unsigned int ui1; char str_tmp[STRLEN]; char keyword[ROCLEN]; char str[150], str2[STRLEN]; int line = 0; det_type crate_det = get_det_type(crate ); if(crate_det == det_unknown) { printf(BOLDRED "\n FATAL: Read_conf_user: Unknown detector type for crate %s \n" RESET, crate); return(-2); } bd_type crate_board = get_board_type(crate ); if(crate_board == bd_unknown) { printf(BOLDRED "\n FATAL: Read_conf_user: Unknown board type for crate %s \n" RESET, crate); return(-2); } /* Take user configuration file name from the flobal config file */ char myfile[STRLEN]="";; switch(crate_board){ case fadc250: if(debug){ printf(" STRING LENGTH = %d %s \n", strlen(fa250[3].conf_user_dir), fa250[3].conf_user_dir); printf(" STRING LENGTH = %d %s \n", strlen(fa250[3].conf_user_ver), fa250[3].conf_user_ver); } if((strlen(fa250[3].conf_user_dir) != 0) && (strlen(fa250[3].conf_user_ver) != 0) ) sprintf(myfile,"%s/%s_%s.cnf", fa250[3].conf_user_dir,crate,fa250[3].conf_user_ver); break; case fadc125: if(debug){ printf(" STRING LENGTH = %d %s \n", strlen(fa125[3].conf_user_dir), fa125[3].conf_user_dir); printf(" STRING LENGTH = %d %s \n", strlen(fa125[3].conf_user_ver), fa125[3].conf_user_ver); } if((strlen(fa125[3].conf_user_dir) != 0) && (strlen(fa125[3].conf_user_ver) != 0) ) if(strlen(fa125[3].conf_user_dir) != 0) sprintf(myfile,"%s/%s_%s.cnf", fa125[3].conf_user_dir,crate,fa125[3].conf_user_ver); break; default: break; } if(strlen(myfile) == 0){ printf(BOLDBLUE "\n No user configuration file is used \n" RESET ); return 0; } /* Open Global Configuration File */ pFile = fopen(myfile, "r"); if(pFile == NULL) { printf(BOLDRED "\n No user configuration file found for crate %s. Proceed with the default configuration \n" RESET, crate); return(0); } printf(BOLDMAGENTA "\n Read User Configuration file %s \n" RESET, myfile); printf(BOLDMAGENTA " Crate = %s Board type = %d, Detector = %d \n" RESET, crate, crate_board, crate_det); while ((ch = getc(pFile)) != EOF) { if(debug) printf(" %d %d %d \n",ch,' ','='); if ( ch == '#' || ch == '#' || ch == '=' ) { while (getc(pFile) != '\n') {} line++; } else if( ch == '\n' ) {line++;} else { ungetc(ch,pFile); if(fgets(str_tmp, sizeof(str_tmp), pFile)){ line++; if(debug) printf(" Board type = %d \n", crate_board); switch(crate_board){ case fadc250: sscanf (str_tmp, "%s %s", keyword, str); if(args != 2) break; if(strcmp(keyword,"FADC250_NOT_USED") == 0) { slot = -1; SCAN_MSK; if(debug) printf("\nReadConfigFile: args = %d \n",args); for(jj=0; jj20) { printf("\n Read_conf_user: Wrong slot number %d, %s\n",slot,str_tmp); continue; } fa250[slot].group = 0; } slot = -1; } SCAN_SLOT("FADC250_SLOTS", fa250[slot].group); if( (slot >= 3) && (slot != 11) && (slot != 12) && (slot < 21)){ SCAN_B_MSKS("FADC250_ADC_MASK", fa250[slot].chDisMask); SCAN_B_MSKS("FADC250_TRG_MASK", fa250[slot].trigMask); if(debug) printf(" CHECK CHANNEL DISABLE MASK NEW = %d %x \n", slot, fa250[slot].chDisMask ); } break; case fadc125: args = sscanf (str_tmp, "%s %s", keyword, str); if(args != 2) break; if(strcmp(keyword,"FADC125_NOT_USED") == 0) { slot = -1; SCAN_MSK; if(debug) printf("\nReadConfigFile: args = %d %s \n",args, str_tmp); for(jj = 0; jj < args; jj++) { slot = msk[jj]; if(slot<3 || slot==11 || slot==12 || slot>20) { printf("\n Read_conf_user: Wrong slot number %d, %s\n",slot,str_tmp); continue; } fa125[slot].group = 0; } slot = -1; } if(strcmp(keyword,"FADC125_SLOTS") == 0) { slot = -1; SCAN_MSK; if(args == 1){ /* Don't allow groups. Each Slot should have an entry in the file */ slot = msk[0]; if(slot < 3 || slot == 11 || slot == 12 || slot > 20){ printf(BOLDRED "\nRead_conf: Wrong slot number %d, %s\n" RESET, slot,str_tmp); return(-2); } } else { printf(BOLDRED "\n Read_conf: Wrong number of slots in FADC_SLOTS %d. Only one slot is allowed. Exit \n" RESET, args); return(-2); } } SCAN_FA125_DAC_THR("FADC125_DAC_CH_", fa125[slot].dac); SCAN_FA125_DAC_THR("FADC125_THR_CH_", fa125[slot].read_thr); if(strncmp(keyword,"FADC125_MASK_",12) == 0){ SCAN_MSK1; ui1 = 0; for(jj = 0; jj < 18; jj++) { if((msk1[jj] < 0) || (msk1[jj] > 1)) { printf("\nReadConfigFile: Wrong mask bit value, %d\n\n",msk1[jj]); return(-9); } ui1 |= (msk1[jj]< 3) { printf("ERROR: mask jj = %d, must be between 0 and 3\n",jj); return(-9); } fa125[slot].mask[jj] = ui1; } break; default: break; } } } } fclose(pFile); return 0; } int get_nbd_fadc250(int print){ int bd; int nbd = 0; for(bd = 3; bd < NBD_FADC250; bd++){ if(fa250[bd].group > 0) nbd++; if(print ) printf(" Group for board in slot %d = %d \n", bd, fa250[bd].group); } return nbd; } int get_nbd_fadc125(int print){ int bd; int nbd = 0; for(bd = 3; bd < NBD_FADC125; bd++){ if(fa125[bd].group > 0) nbd++; if(print ) printf(" Group for board in slot %d = %d \n", bd, fa125[bd].group); } return nbd; } void print_fadc250_conf(int slot){ int ch; if(fa250[slot].group <= 0) printf(" print_fadc250_conf: FADC250 in slot %d is not used in the configuration \n", slot); printf("\n===================================================\n"); printf("Slot = %d \n", slot); printf("Used = %d \n", fa250[slot].group); printf("Processing firmware = 0x%x \n", fa250[slot].f_rev); printf("Control firmware = 0x%x \n", fa250[slot].b_rev); printf(" FADC250_TYPE = 0x%x \n", fa250[slot].b_ID); printf(" FADC250_SN = %s \n", fa250[slot].SerNum); printf(" FADC250_MODE = %d \n", fa250[slot].mode); printf(" FADC250_W_OFFSET = %d \n", fa250[slot].winOffset); printf(" FADC250_W_WIDTH = %d \n", fa250[slot].winWidth); printf(" FADC250_NSB = %d \n", fa250[slot].nsb); printf(" FADC250_NSA = %d \n", fa250[slot].nsa); printf(" FADC250_NPEAK = %d \n", fa250[slot].npeak); printf(" FADC250_ADC_MASK = 0x%x \n", fa250[slot].chDisMask); printf(" FADC250_DAC = "); for(ch = 0; ch < MAX_FADC250_CH; ch++) printf(" %d", fa250[slot].dac[ch]); printf("\n"); printf(" FADC250_READ_THR = "); for(ch = 0; ch < MAX_FADC250_CH; ch++) printf(" %d", fa250[slot].read_thr[ch]); printf("\n"); printf("\n"); printf(" FADC250_TRIG_THR = %d \n", fa250[slot].trig_thr); printf(" FADC250_TRIG_NSB = %d \n", fa250[slot].trig_nsb); printf(" FADC250_TRIG_NSA = %d \n", fa250[slot].trig_nsa); printf(" FADC250_TRIG_MASK = 0x%x \n", fa250[slot].trigMask); printf(" FADC250_TRIG_BL = "); for(ch = 0; ch < MAX_FADC250_CH; ch++) printf(" %d", fa250[slot].trig_bl[ch]); printf("\n"); printf("\n"); printf(" FADC250_COM_DIR = %s \n", fa250[slot].conf_common_dir); printf(" FADC250_COM_VER = %s \n", fa250[slot].conf_common_dir); printf(" FADC250_USER_DIR = %s \n", fa250[slot].conf_user_dir); printf(" FADC250_USER_VER = %s \n", fa250[slot].conf_user_ver); } void print_fadc125_conf(int slot){ int ch; if(fa125[slot].group <= 0){ printf("\n"); printf(" print_fadc125_conf: FADC125 in slot %d is not used in the configuration \n", slot); } printf("========================================================================\n"); printf("Slot = %d \n", slot); printf("Used = %d \n", fa125[slot].group); printf("Firmware version = 0x%x \n", fa125[slot].f_rev); printf("FrontEnd version = 0x%x \n", fa125[slot].b_rev); printf("Processing version = 0x%x \n", fa125[slot].b_rev); printf(" FADC125_TYPE = 0x%x \n", fa125[slot].b_ID); printf(" FADC125_SN = %s \n", fa125[slot].SerNum); printf(" FADC125_MODE = %d \n", fa125[slot].mode); printf(" FADC125_W_OFFSET = %d \n", fa125[slot].winOffset); printf(" FADC125_W_WIDTH = %d \n", fa125[slot].winWidth); printf(" FADC125_NSB = %d \n", fa125[slot].nsb); printf(" FADC125_NSA = %d \n", fa125[slot].nsa); printf(" FADC125_NPEAK = %d \n", fa125[slot].npeak); printf("\n"); printf("\n FADC125_DAC_CH_00_17 "); for(ch = 0; ch < 18; ch++) printf(" %d ", fa125[slot].dac[ch]); printf("\n FADC125_DAC_CH_18_35 "); for(ch = 18; ch < 36; ch++) printf(" %d ", fa125[slot].dac[ch]); printf("\n FADC125_DAC_CH_36_53 "); for(ch = 36; ch < 54; ch++) printf(" %d ", fa125[slot].dac[ch]); printf("\n FADC125_DAC_CH_54_71 "); for(ch = 54; ch < 72; ch++) printf(" %d ", fa125[slot].dac[ch]); printf("\n"); printf("\n"); printf(" FADC125_THR_CH_00_17 "); for(ch = 0; ch < 18; ch++) printf(" %d ", fa125[slot].read_thr[ch]); printf("\n FADC125_THR_CH_18_35 "); for(ch = 18; ch < 36; ch++) printf(" %d ", fa125[slot].read_thr[ch]); printf("\n FADC125_THR_CH_36_53 "); for(ch = 36; ch < 54; ch++) printf(" %d ", fa125[slot].read_thr[ch]); printf("\n FADC125_THR_CH_54_71 "); for(ch = 54; ch < 72; ch++) printf(" %d ", fa125[slot].read_thr[ch]); printf("\n"); printf("\n FADC125_MASK_00_17 "); for(ch = 0; ch < 18; ch++) if( (fa125[slot].mask[0] & (1 << ch)) == 0) printf(" 0"); else printf(" 1"); printf("\n FADC125_MASK_18_35 "); for(ch = 0; ch < 18; ch++) if( (fa125[slot].mask[1] & (1 << ch)) == 0) printf(" 0"); else printf(" 1"); printf("\n FADC125_MASK_36_53 "); for(ch = 0; ch < 18; ch++) if( (fa125[slot].mask[2] & (1 << ch)) == 0) printf(" 0"); else printf(" 1"); printf("\n FADC125_MASK_54_71 "); for(ch = 0; ch < 18; ch++) if( (fa125[slot].mask[3] & (1 << ch)) == 0) printf(" 0"); else printf(" 1"); printf("\n"); printf("\n"); printf(" FADC125_COM_DIR = %s \n", fa125[slot].conf_common_dir); printf(" FADC125_COM_VER = %s \n", fa125[slot].conf_common_ver); printf(" FADC125_USER_DIR = %s \n", fa125[slot].conf_user_dir); printf(" FADC125_USER_VER = %s \n", fa125[slot].conf_user_ver); } void print_ti_conf(){ int opt_port, port; printf("\n========================================================================\n"); printf("================== TI CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); printf("TI_MASTER: %d \n", ti_bd.ti_master ); printf("\n"); printf("TI_MASTER_TRIG: %d \n", ti_bd.ti_master_trig ); printf("\n"); printf(" TI_SOFT_TRIG: \n"); printf(" Trigger type (type 1 or 2 for playback): %d \n", ti_bd.ti_soft_trig[0] ); printf(" Number of events to trigger: %d \n", ti_bd.ti_soft_trig[1] ); printf(" Period multiplier (depends on range 0-0x7FFF): %d \n", ti_bd.ti_soft_trig[2] ); printf(" Range: %d \n", ti_bd.ti_soft_trig[3] ); printf("\n"); printf("TI_FP_INPUTS = "); for(port = 0; port < 16; port++){ if( ti_bd.ti_fp_inputs & (1 << port)) printf(" %d", port+1); } printf("\n"); printf(" 0x%x \n",ti_bd.ti_fp_inputs); printf("TI_FIBER_EN: \n"); for(opt_port = 2; opt_port < 7; opt_port++) if(ti_bd.ti_fiber_en & (1 << (opt_port - 1))) printf(" %d ", opt_port); printf("\n"); printf("\n"); printf("TI_FIBER_LATENCY_OFFSET: 0x%x \n", ti_bd.fiber_latency); } void print_ts_conf(){ int slot; int port; printf("\n========================================================================\n"); printf("================== TS CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); printf("TS_TD_SLOTS = "); for(slot = 3; slot < 21; slot++){ if( ts_bd.ts_td_slots & (1 << slot)) printf(" %d", slot); } printf("\n"); printf(" 0x%x \n",ts_bd.ts_td_slots); printf("\n"); printf("TS_FP_INPUTS = "); for(port = 0; port < 16; port++){ if( ts_bd.ts_fp_inputs & (1 << port)) printf(" %d", port+1); } printf("\n"); printf(" 0x%x \n",ts_bd.ts_fp_inputs); printf("TS_MASTER_TRIG = %d\n", ts_bd.ts_master_trig); printf("BLOCKLEVEL = %d\n", ts_bd.blocklevel); printf("BUFFERLEVEL = %d\n", ts_bd.bufferlevel); printf("TS_SOFT_TRIG: \n"); printf(" Trigger type (type 1 or 2 for playback): %d \n", ts_bd.ts_soft_trig[0] ); printf(" Number of events to trigger: %d \n", ts_bd.ts_soft_trig[1] ); printf(" Period multiplier (depends on range 0-0x7FFF): %d \n", ts_bd.ts_soft_trig[2] ); printf(" Range: %d \n", ts_bd.ts_soft_trig[3] ); } void print_le_conf(){ int slot, ch; int port; printf("\n========================================================================\n"); printf("================== LE CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); for(slot = 3; slot < NBD_DSC2; slot++){ printf(" Slot = %d \n",slot); printf(" TDCWidth = %d TRGWidth = %d \n", dsc[slot].TDCWidth, dsc[slot].TRGWidth); printf(" TDCThreshold = "); for(ch = 0; ch < MAX_DSC2_CH; ch++){ printf(" %d", dsc[slot].TDCThreshold[ch]); } printf(" \n"); printf(" TRGThreshold = "); for(ch = 0; ch < MAX_DSC2_CH; ch++){ printf(" %d", dsc[slot].TRGThreshold[ch]); } printf(" \n"); printf(" \n"); } } void print_caen1290_conf(){ int slot, ch; printf("\n========================================================================\n"); printf("================== CAEN 1290 TDC CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); for(slot = 3; slot < NBD_TDC1290; slot++){ printf(" Slot = %d \n",slot); printf(" TDC1290_W_WIDTH = %d \n", caen1290[slot].window_width); printf(" TDC1290_W_OFFSET = %d \n", caen1290[slot].window_offset); printf(" TDC1290_W_EXTRA = %d \n", caen1290[slot].window_extra); printf(" TDC1290_W_REJECT = %d \n", caen1290[slot].window_reject); printf("\n"); printf(" TDC1290_BLT_EVENTS = %d \n", caen1290[slot].blt_Events); printf(" TDC1290_N_HITS = %d \n", caen1290[slot].n_Hits); printf(" TDC1290_ALMOSTFULL = %d \n", caen1290[slot].almostFullLevel); printf(" TDC1290_OUT_PROG = %d \n", caen1290[slot].outProgControl); printf("\n"); printf(" TDC1290_A24_A32 = %d \n", caen1290[slot].a24_a32); printf(" TDC1290_SNGL_BLT = %d \n", caen1290[slot].sngl_blt_mblt); printf(" TDC1290_SST_RATE = %d \n", caen1290[slot].sst_rate); printf(" TDC1290_BERR_FIFO = %d \n", caen1290[slot].berr_fifo); printf(" TDC1290_EDGE = %d \n", caen1290[slot].edge); printf(" \n"); } }