#ifdef Linux_vme #include #include #include #include #include // sleep, usleep #include "sspLib.h" #include "sspLib_rich.h" #include "jvme.h" #define NAMESCALER "ssprich_scaler_138.txt" // if you modify this, please modify below accordingly //#define RICH_IN_THRESHOLDS "/home/clasrun/rich/suite1.0/maps/threshold.txt"; //#define RICH_IN_GAINS "/home/clasrun/rich/suite1.0/maps/gain.txt"; //#define RICH_OUT_TEMPERATURE "/home/clasrun/rich/suite1.0/data/temperature/ssprich_Temperatures.txt"; int sspRich_ReadTemperature(int slot,int fiber); int sspRich_InitMarocReg(int slot,int fiber,int asic,int threshold,int gain); int GetThreshold(int slot,int fiber,int asic); int ResetGains(); int LoadGains(); int gmap[MAX_VME_SLOTS+1][RICH_FIBER_NUM][3][64];// slot, fiber, asic, channel //---------------------------------------- int main(int argc, char *argv[]){ //---------------------------------------- int nssp = 0; int id; int geo; int slot=0; int i; int j; int fibers; int nfibers = 0; int nmarocs = 0; int asic; int ch; unsigned int maroc[RICH_CHAN_NUM]; int threshold = 300; int gain = 64; int ctestAmplitude= 0; int ret; int pulserFrequency=1000; int duration =1; int ref; int absChannel; FILE * fout; char foutName[80]=NAMESCALER; int skipSSPRichinit; int printscreen=0; /* Checks Arguments*/ printf("argc is %d\n",argc); if(argc==5) { threshold = atoi(argv[1]); gain = atoi(argv[2]); ctestAmplitude = atoi(argv[3]); duration = atoi(argv[4]); // printscreen=atoi(argv[5]); } else { printf("\nUsage: ssptest [threshold; 0 to enable map] [gain; 0 to enable map] [CTEST Amplitude] [Scaler Duration]\n"); printf("\nExample: ssptest 230 64 0 1\n"); exit(0); } /* Open the default VME windows */ vmeOpenDefaultWindows(); printf("\n"); sspInit(0, 0, 1, SSP_INIT_NO_INIT | SSP_INIT_SKIP_FIRMWARE_CHECK); nssp = sspGetNssp(); printf("Found %d SSP\n",nssp); for(i=0;i0){ for(i=0;i0)sspRich_SetCTestSource(slot,j, RICH_SD_CTEST_SRC_SEL_SSP); else sspRich_SetCTestSource(slot,j, RICH_SD_CTEST_SRC_SEL_0); } } } printf("OK\n"); // SCALERS for(i=0;i=limit){ printf("TIME %d ",(int)time(NULL)); printf("SLOT %d FIBER %d ",slot, fiber); printf("FPGA %6.3f ",(float)mon.temps.fpga / 1000.0f); printf("REG1 %6.3f ",(float)mon.temps.regulator[0] / 1000.0f); printf("REG2 %6.3f ",(float)mon.temps.regulator[1] / 1000.0f); printf("[Celsius]"); printf("Attention: Temperature too warm!"); printf("\n"); } return 0; } //---------------------------------------- int GetThreshold(int slot,int fiber,int asic){ //---------------------------------------- FILE * fin; int var[4]; int pri = 0; int thr; int thr_default = 230; //const char * filename = RICH_IN_THRESHOLDS; char filename[200]; sprintf(filename, "%s/maps/threshold.txt", getenv("RICH_SUITE")); thr = thr_default; fin = fopen(filename,"r"); if(!fin) { printf("Threshold file %s not found...\n"); exit(1); } else { while(fscanf(fin,"%d %d %d %d \n",var,var+1,var+2,var+3)!=EOF) // slot, fiber, asic, threshold { if(pri) printf("%d %3d %d %4d\n",var[0],var[1],var[2],var[3]); if(var[0]==slot && var[1]==fiber && var[2]==asic){ thr = var[3]; break; } } fclose(fin); } return thr; } //---------------------------------------- int ResetGains(){ //---------------------------------------- int slot, fiber, asic, channel; int gain_default=64; for(slot=0;slot