diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index c250f3b76..5fc46287a 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -1,5 +1,7 @@ CFLAGS= -DC_ONLY -FLAGS+= -DDACS_INT #-DVERBOSE -DVERYVERBOSE +#FLAGS+= #-DVERBOSE -DVERYVERBOSE +#DFLAGS= -DDACS_INT + INCLUDES= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis #EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom @@ -25,23 +27,23 @@ doc: $(SRC_H) $(SRC_CLNT) mythenServer: $(SRC_MYTHEN_SVC) - $(CC) $(SRC_MYTHEN_SVC) $(CFLAGS) $(FLAGS) $(INCLUDES) -ImythenDetectorServer -DVIRTUAL -lm -D MCB_FUNCS -DC_ONLY -DVERBOSE + $(CC) $(SRC_MYTHEN_SVC) $(CFLAGS) $(FLAGS) $(DFLAGS) $(INCLUDES) -ImythenDetectorServer -DVIRTUAL -lm -D MCB_FUNCS -DC_ONLY -DVERBOSE mv a.out mythenServer picassoServer: $(SRC_MYTHEN_SVC) - $(CC) $(SRC_MYTHEN_SVC) $(CFLAGS) $(FLAGS) $(INCLUDES) -ImythenDetectorServer -D VIRTUAL -lm -DMCB_FUNCS -DPICASSOD -DC_ONLY + $(CC) $(SRC_MYTHEN_SVC) $(CFLAGS) $(FLAGS) $(DFLAGS) $(INCLUDES) -ImythenDetectorServer -D VIRTUAL -lm -DMCB_FUNCS -DPICASSOD -DC_ONLY mv a.out picassoServer %.o : %.cpp %.h - $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(FLAGS) $(EPICSFLAGS) + $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) package: $(OBJS) - $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(FLAGS) $(EPICSFLAGS) + $(CXX) -shared -Wl,-soname,libSlsDetector.so -o libSlsDetector.so $(OBJS) -lc $(INCLUDES) $(DFLAGS) $(FLAGS) $(EPICSFLAGS) ar rcs libSlsDetector.a $(OBJS) clean: diff --git a/slsDetectorSoftware/commonFiles/communication_funcs.c b/slsDetectorSoftware/commonFiles/communication_funcs.c index 63b8e1f00..683819dc2 100755 --- a/slsDetectorSoftware/commonFiles/communication_funcs.c +++ b/slsDetectorSoftware/commonFiles/communication_funcs.c @@ -362,13 +362,13 @@ int sendModule(int file_des, sls_detector_module *myMod) { #ifdef VERBOSE printf("module %d of size %d sent\n",myMod->module, ts); #endif - ts+= sendDataOnly(file_des,myMod->dacs,sizeof(double)*nDacs); + ts+= sendDataOnly(file_des,myMod->dacs,sizeof(dacs_t)*nDacs); #ifdef VERBOSE printf("dacs %d of size %d sent\n",myMod->module, ts); for (idac=0; idac< nDacs; idac++) printf("dac %d is %d\n",idac,myMod->dacs[idac]); #endif - ts+= sendDataOnly(file_des,myMod->adcs,sizeof(double)*nAdcs); + ts+= sendDataOnly(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs); #ifdef VERBOSE printf("adcs %d of size %d sent\n",myMod->module, ts); #endif @@ -432,15 +432,15 @@ int receiveChip(int file_des, sls_detector_chip* myChip) { int receiveModule(int file_des, sls_detector_module* myMod) { - double *dacptr=myMod->dacs; - double *adcptr=myMod->adcs; + dacs_t *dacptr=myMod->dacs; + dacs_t *adcptr=myMod->adcs; int *chipptr=myMod->chipregs, *chanptr=myMod->chanregs; int ts=0; int nChips, nchipold=myMod->nchip, nchipdiff; int nChans, nchanold=myMod->nchan, nchandiff; int nDacs, ndold=myMod->ndac, ndacdiff; int nAdcs, naold=myMod->nadc, nadcdiff; - + int id=0; ts+= receiveDataOnly(file_des,myMod,sizeof(sls_detector_module)); @@ -490,29 +490,33 @@ int receiveModule(int file_des, sls_detector_module* myMod) { printf("received %d adcs\n",nAdcs); #endif if (ndacdiff<=0) { - ts+=receiveDataOnly(file_des,myMod->dacs, sizeof(double)*nDacs); + ts+=receiveDataOnly(file_des,myMod->dacs, sizeof(dacs_t)*nDacs); #ifdef VERBOSE printf("dacs received\n"); + for (id=0; iddacs[id]); + + #endif } else { - dacptr=malloc(ndacdiff*sizeof(double)); + dacptr=malloc(ndacdiff*sizeof(dacs_t)); myMod->ndac=ndold; - ts+=receiveDataOnly(file_des,myMod->dacs, sizeof(double)*ndold); - ts+=receiveDataOnly(file_des,dacptr, sizeof(double)*ndacdiff); + ts+=receiveDataOnly(file_des,myMod->dacs, sizeof(dacs_t)*ndold); + ts+=receiveDataOnly(file_des,dacptr, sizeof(dacs_t)*ndacdiff); free(dacptr); return FAIL; } if (nadcdiff<=0) { - ts+=receiveDataOnly(file_des,myMod->adcs, sizeof(double)*nAdcs); + ts+=receiveDataOnly(file_des,myMod->adcs, sizeof(dacs_t)*nAdcs); #ifdef VERBOSE printf("adcs received\n"); #endif } else { - adcptr=malloc(nadcdiff*sizeof(double)); + adcptr=malloc(nadcdiff*sizeof(dacs_t)); myMod->nadc=naold; - ts+=receiveDataOnly(file_des,myMod->adcs, sizeof(double)*naold); - ts+=receiveDataOnly(file_des,adcptr, sizeof(double)*nadcdiff); + ts+=receiveDataOnly(file_des,myMod->adcs, sizeof(dacs_t)*naold); + ts+=receiveDataOnly(file_des,adcptr, sizeof(dacs_t)*nadcdiff); free(adcptr); return FAIL; } diff --git a/slsDetectorSoftware/mythenDetectorServer/Makefile b/slsDetectorSoftware/mythenDetectorServer/Makefile index 41c0ff11f..a03767745 100755 --- a/slsDetectorSoftware/mythenDetectorServer/Makefile +++ b/slsDetectorSoftware/mythenDetectorServer/Makefile @@ -14,6 +14,7 @@ SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_func OBJS= $(SRCS:%.c=%.o) CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DVERBOSE +#-DDACS_INT #-DVERYVERBOSE #-Werror diff --git a/slsDetectorSoftware/mythenDetectorServer/mcb_funcs.c b/slsDetectorSoftware/mythenDetectorServer/mcb_funcs.c index e3f3d0eba..88b599e27 100755 --- a/slsDetectorSoftware/mythenDetectorServer/mcb_funcs.c +++ b/slsDetectorSoftware/mythenDetectorServer/mcb_funcs.c @@ -38,8 +38,8 @@ const int noneSelected=-1; sls_detector_module *detectorModules=NULL; int *detectorChips=NULL; int *detectorChans=NULL; -float *detectorDacs=NULL; -float *detectorAdcs=NULL; +dacs_t *detectorDacs=NULL; +dacs_t *detectorAdcs=NULL; //int numberOfProbes; @@ -61,8 +61,8 @@ int initDetector() { detectorChips=malloc(n*NCHIP*sizeof(int)); detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int)); - detectorDacs=malloc(n*NDAC*sizeof(float)); - detectorAdcs=malloc(n*NADC*sizeof(float)); + detectorDacs=malloc(n*NDAC*sizeof(dacs_t)); + detectorAdcs=malloc(n*NADC*sizeof(dacs_t)); #ifdef VERBOSE printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n); printf("chips from 0x%x to 0x%x\n",detectorChips, detectorChips+n*NCHIP); @@ -440,6 +440,9 @@ int program_one_dac(int addr, int value, int imod) { // sls_detector_module *myMod; control=9+addr; + int ireg; + + printf("programming dac %d value %d module %d\n",addr, value,imod); #ifdef MAX5533 @@ -474,12 +477,16 @@ int program_one_dac(int addr, int value, int imod) { #endif idac=sDac*2+addr; + + ireg=idac; + if (idac==VCAL) { idac=RGPR; } else if (idac==RGPR){ idac=VCAL; } + if (detectorDacs) { sMod=imod; if (imod==ALLMOD) @@ -488,13 +495,13 @@ int program_one_dac(int addr, int value, int imod) { if (imod>=0 && imoddacs[idac]=v; - detectorDacs[idac+NDAC*imod]=v; + detectorDacs[ireg+NDAC*imod]=v; //#ifdef VERBOSE #ifdef VERBOSE printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, detectorDacs+idac+NDAC*imod); #endif - setDACRegister(idac,v,imod); + setDACRegister(ireg,v,imod); /* @@ -542,7 +549,7 @@ int program_one_dac(int addr, int value, int imod) { //#endif } else if (imod==ALLMOD) { for (im=0; im