diff --git a/slsDetectorSoftware/jungfrauDetectorServer/Makefile b/slsDetectorSoftware/jungfrauDetectorServer/Makefile index 2a3101d1f..6b3fc4bd4 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/Makefile +++ b/slsDetectorSoftware/jungfrauDetectorServer/Makefile @@ -6,7 +6,7 @@ CROSS = bfin-uclinux- CC = $(CROSS)gcc -CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DJUNGFRAU_DHANYA #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER +CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER PROGS= jungfrauDetectorServerTest diff --git a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c index c4494ece4..312c9182e 100755 --- a/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/jungfrauDetectorServer/firmware_funcs.c @@ -110,22 +110,20 @@ enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_ int withGotthard = 0; -#ifdef MCB_FUNCS -extern const int nChans; -extern const int nChips; -//extern const int nDacs; -//extern const int nAdcs; -#endif -#ifndef MCB_FUNCS - -const int nChans=NCHAN; -const int nChips=NCHIP; -const int nDacs=NDAC; -const int nAdcs=NADC; -#endif +/**is not const because this value will change after initDetector, is removed from mcb_funcs.c cuz its not used anywhere + * why is this used anywhere instead of macro*/ +int nChans=NCHAN; +int nChips=NCHIP; +int nDacs=NDAC; +int nAdcs=NADC; extern enum detectorType myDetectorType; - +/** for jungfrau reinitializing macro later in server_funcs.c in initDetector*/ +extern int N_CHAN; +extern int N_CHIP; +extern int N_DAC; +extern int N_ADC; +extern int N_CHANS; int mapCSP0(void) { printf("Mapping memory\n"); @@ -1360,7 +1358,7 @@ ROI *setROI(int nroi,ROI* arg,int *retvalsize, int *ret) { for (i=0; i=0 && ich=0 && ichdacs=detectorDacs+imod*NDAC; - (detectorModules+imod)->adcs=detectorAdcs+imod*NADC; + (detectorModules+imod)->dacs=detectorDacs+imod*N_DAC; + (detectorModules+imod)->adcs=detectorAdcs+imod*N_ADC; if(myDetectorType != JUNGFRAU){ - (detectorModules+imod)->chipregs=detectorChips+imod*NCHIP; - (detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN; + (detectorModules+imod)->chipregs=detectorChips+imod*N_CHIP; + (detectorModules+imod)->chanregs=detectorChans+imod*N_CHIP*N_CHAN; } - (detectorModules+imod)->ndac=NDAC; - (detectorModules+imod)->nadc=NADC; - (detectorModules+imod)->nchip=NCHIP; - (detectorModules+imod)->nchan=NCHIP*NCHAN; + (detectorModules+imod)->ndac=N_DAC; + (detectorModules+imod)->nadc=N_ADC; + (detectorModules+imod)->nchip=N_CHIP; + (detectorModules+imod)->nchan=N_CHIP*N_CHAN; (detectorModules+imod)->module=imod; (detectorModules+imod)->gain=0; (detectorModules+imod)->offset=0; @@ -495,15 +515,15 @@ int selChip(const int chip,int imod) { /* sMod=allSelected; */ /* if (imod>=0 && imod=0 && imod0 && myo>0) { */ -/* //ethr=(myo-detectorDacs[VTHRESH+imod*NDAC])*1000/myg; */ +/* //ethr=(myo-detectorDacs[VTHRESH+imod*N_DAC])*1000/myg; */ /* ethr=(myo-setDACRegister(VDAC0,-1,imod))*1000/myg;//edited by dhanya */ /* // else */ @@ -659,7 +679,7 @@ int selChip(const int chip,int imod) { /* } */ /* #ifdef VERBOSE */ -/* //printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo, detectorDacs[VTHRESH+imod*NDAC]); */ +/* //printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo, detectorDacs[VTHRESH+imod*N_DAC]); */ /* printf("module=%d gain=%f, offset=%f, dacu=%d\n",imod, myg, myo,(int)(setDACRegister(VDAC0,-1,imod)));//edited by dhanya */ /* printf("Threshold energy of module %d is %d eV\n", imod, ethr); */ /* #endif */ @@ -737,7 +757,7 @@ int selChip(const int chip,int imod) { /* if (detectorDacs) { */ /* if (imodndac) */ -/* return (detectorDacs[ind+imod*NDAC]); */ +/* return (detectorDacs[ind+imod*N_DAC]); */ /* } */ /* return FAIL; */ /* *\/ */ @@ -958,7 +978,7 @@ int getChannelbyNumber(sls_detector_channel* myChan) { if (detectorChans) { if (imod=0) { if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip) - myChan->reg=detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan]; + myChan->reg=detectorChans[imod*N_CHAN*N_CHIP+ichip*N_CHAN+ichan]; return OK; } } @@ -970,7 +990,7 @@ int getTrimbit(int imod, int ichip, int ichan) { if (detectorChans) { if (imod=0) if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip) - return (detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan] & TRIM_DR); + return (detectorChans[imod*N_CHAN*N_CHIP+ichip*N_CHAN+ichan] & TRIM_DR); } return -1; @@ -994,8 +1014,8 @@ int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod) if (sChan==allSelected) { // printf("initializing all channels ft=%d coe=%d\n",ft,coe); chanmi=0; - chanma=NCHAN; - } else if (sChan==noneSelected || sChan>NCHAN || sChan<0) { + chanma=N_CHAN; + } else if (sChan==noneSelected || sChan>N_CHAN || sChan<0) { // printf("initializing no channels ft=%d coe=%d\n",ft,coe); chanmi=0; chanma=-1; @@ -1008,8 +1028,8 @@ int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod) if (sChip==allSelected) { // printf("initializing all chips\n"); chipmi=0; - chipma=NCHIP; - } else if (sChip==noneSelected || sChip>NCHIP || sChip<0) { + chipma=N_CHIP; + } else if (sChip==noneSelected || sChip>N_CHIP || sChip<0) { // printf("initializing no chips\n"); chipmi=0; chipma=-1; @@ -1037,12 +1057,12 @@ int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod) for (ichip=chipmi; ichipnchip) { - myChip->reg=detectorChips[ichip+imod*NCHIP]; - myChip->nchan=NCHAN; - myChip->chanregs=detectorChans+imod*NCHAN*NCHIP+ichip*NCHIP; + myChip->reg=detectorChips[ichip+imod*N_CHIP]; + myChip->nchan=N_CHAN; + myChip->chanregs=detectorChans+imod*N_CHAN*N_CHIP+ichip*N_CHIP; return OK; } } @@ -1350,8 +1370,8 @@ int initChip(int obe, int ow,int imod){ if (sChip==allSelected) { chipmi=0; - chipma=NCHIP; - } else if (sChip==noneSelected || sChip>NCHIP || sChip<0) { + chipma=N_CHIP; + } else if (sChip==noneSelected || sChip>N_CHIP || sChip<0) { chipmi=0; chipma=-1; } else { @@ -1375,9 +1395,9 @@ int initChip(int obe, int ow,int imod){ for (im=modmi; imNCHIP || sChip<0) { + chipma=N_CHIP; + } else if (sChip==noneSelected || sChip>N_CHIP || sChip<0) { chipmi=0; chipma=-1; } else { @@ -1475,9 +1495,9 @@ int initChipWithProbes(int obe, int ow,int nprobes, int imod){ for (im=modmi; im0 && i%2==0) { printf("Shift stsel: module %d chip %i bit %d read %d instead of %d \n",k,j,i,val & 1<< j, i%2); result++; @@ -1958,7 +1978,7 @@ int testShiftStSel(int imod) { int testDataInOut(int num, int imod) { - int val[NCHIP*nModX], result=OK; + int val[N_CHIP*nModX], result=OK; int ich, ichip; setCSregister(ALLMOD); printf("Testing data in out for module %d pattern 0x%x\n", imod, num); @@ -1968,14 +1988,14 @@ int testDataInOut(int num, int imod) { setCSregister(ALLMOD); initChip(0, 0,ALLMOD); clearSSregister(ALLMOD); - for (ich=0; ich=getNModBoard()) ret=FAIL; - if (myChan.chip>=NCHIP) + if (myChan.chip>=N_CHIP) ret=FAIL; - if (myChan.chan>=NCHAN) + if (myChan.chan>=N_CHAN) ret=FAIL; if (myChan.module<0) myChan.module=ALLMOD; @@ -1322,13 +1339,13 @@ int get_channel(int file_des) { } if (ret==OK) { ret=FAIL; - if (ichip>=0 && ichip=0 && ichip=0 && ichan=0 && ichan=NCHIP) + if (myChip.chip>=N_CHIP) ret=FAIL; } if (differentClients==1 && lockStatus==1) { @@ -1456,7 +1473,7 @@ int get_chip(int file_des) { } if (ret==OK) { ret=FAIL; - if (ichip>=0 && ichip=0 && ichip