mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 23:10:02 +02:00
mythenDetectorServer now works with dacs_t and the commands vpreamp and vcalibration respond correctly
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@226 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
cd7cfadac8
commit
362ba2af11
@ -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:
|
||||
|
@ -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; id<nDacs; id++)
|
||||
printf("dac %d val %d\n",id, myMod->dacs[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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 && imod<nModX) {
|
||||
// myMod=detectorModules+imod;
|
||||
//(detectorModules+imod)->dacs[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<nModX; im++) {
|
||||
detectorDacs[idac+NDAC*im]=v;
|
||||
detectorDacs[ireg+NDAC*im]=v;
|
||||
|
||||
/*
|
||||
#ifdef VERBOSE
|
||||
@ -592,7 +599,7 @@ int program_one_dac(int addr, int value, int imod) {
|
||||
printf("after setting dac %d module %d -- %x -- %x addr %d\n",idac, im, reg, bus_r(MOD_DACS2_REG+(im<<SHIFTMOD)));
|
||||
#endif
|
||||
*/
|
||||
setDACRegister(idac,v,im);
|
||||
setDACRegister(ireg,v,im);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -640,12 +647,19 @@ int set_one_dac(int imod) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
float initDACbyIndex(int ind,float val, int imod) {
|
||||
dacs_t initDACbyIndex(int ind,dacs_t ival, int imod) {
|
||||
int v;
|
||||
const float partref[NDAC]=PARTREF;
|
||||
const float partr1[NDAC]=PARTR1;
|
||||
const float partr2[NDAC]=PARTR2;
|
||||
|
||||
float val;
|
||||
#ifdef DACS_INT
|
||||
val=((float)ival)*1E-3;
|
||||
#else
|
||||
val=ival;
|
||||
#endif
|
||||
|
||||
float ref=partref[ind];
|
||||
float r1=partr1[ind];
|
||||
float r2=partr2[ind];
|
||||
@ -657,10 +671,10 @@ float initDACbyIndex(int ind,float val, int imod) {
|
||||
return (v*DAC_MAX/DAC_DR+ref*r1/r2)/(1+r1/r2);
|
||||
}
|
||||
|
||||
float initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
dacs_t initDACbyIndexDACU(int ind, dacs_t val, int imod) {
|
||||
|
||||
const float daccs[NDAC]=DACCS;
|
||||
const float dacaddr[NDAC]=DACADDR;
|
||||
const int daccs[NDAC]=DACCS;
|
||||
const int dacaddr[NDAC]=DACADDR;
|
||||
|
||||
int cs=daccs[ind];
|
||||
int addr=dacaddr[ind];
|
||||
@ -820,7 +834,7 @@ int setThresholdEnergy(int ethr) {
|
||||
|
||||
|
||||
|
||||
float getDACbyIndexDACU(int ind, int imod) {
|
||||
dacs_t getDACbyIndexDACU(int ind, int imod) {
|
||||
/*
|
||||
if (detectorDacs) {
|
||||
if (imod<getNModBoard())
|
||||
@ -923,7 +937,7 @@ int setSettings(int i) {
|
||||
irgsh2=detectorDacs[imod*NDAC+RGSH2];
|
||||
*/
|
||||
|
||||
irgpr=setDACRegister(4,-1,imod);
|
||||
irgpr=setDACRegister(RGPR,-1,imod);
|
||||
irgsh1=setDACRegister(RGSH1,-1,imod);
|
||||
irgsh2=setDACRegister(RGSH2,-1,imod);
|
||||
for (is=STANDARD; is<UNDEFINED; is++) {
|
||||
@ -936,7 +950,7 @@ int setSettings(int i) {
|
||||
#endif
|
||||
for (imod=1; imod<nModX; imod++) {
|
||||
if (isett!=UNDEFINED) {
|
||||
irgpr=setDACRegister(4,-1,imod);
|
||||
irgpr=setDACRegister(RGPR,-1,imod);
|
||||
irgsh1=setDACRegister(RGSH1,-1,imod);
|
||||
irgsh2=setDACRegister(RGSH2,-1,imod);
|
||||
/*
|
||||
|
@ -100,9 +100,9 @@ int set_one_dac(int imod);
|
||||
int initDAC(int dac_cs, int dac_addr, int value,int imod );
|
||||
int initDACs(int* v,int imod );
|
||||
int setSettings(int i);
|
||||
float initDACbyIndex(int ind,float val, int imod);
|
||||
float initDACbyIndexDACU(int ind,int val, int imod);
|
||||
float getDACbyIndexDACU(int ind, int imod);
|
||||
dacs_t initDACbyIndex(int ind,dacs_t val, int imod);
|
||||
dacs_t initDACbyIndexDACU(int ind,dacs_t val, int imod);
|
||||
dacs_t getDACbyIndexDACU(int ind, int imod);
|
||||
int getThresholdEnergy();
|
||||
int setThresholdEnergy(int ethr);
|
||||
/* Initialization*/
|
||||
|
@ -842,13 +842,13 @@ int read_register(int file_des) {
|
||||
|
||||
int set_dac(int file_des) {
|
||||
|
||||
float retval;
|
||||
dacs_t retval;
|
||||
int ret=OK;
|
||||
int arg[2];
|
||||
enum dacIndex ind;
|
||||
int imod;
|
||||
int n;
|
||||
float val;
|
||||
dacs_t val;
|
||||
int idac=0;
|
||||
|
||||
sprintf(mess,"Can't set DAC\n");
|
||||
@ -954,7 +954,7 @@ add possible potentiometers like in chiptest board!!!!!!!!!!!!!!!
|
||||
|
||||
int get_adc(int file_des) {
|
||||
|
||||
float retval;
|
||||
dacs_t retval;
|
||||
int ret=OK;
|
||||
int arg[2];
|
||||
enum dacIndex ind;
|
||||
@ -1309,11 +1309,15 @@ int get_chip(int file_des) {
|
||||
|
||||
}
|
||||
int set_module(int file_des) {
|
||||
|
||||
|
||||
sls_detector_module myModule;
|
||||
int *myChip=malloc(NCHIP*sizeof(int));
|
||||
int *myChan=malloc(NCHIP*NCHAN*sizeof(int));
|
||||
float *myDac=malloc(NDAC*sizeof(int));
|
||||
float *myAdc=malloc(NADC*sizeof(int));
|
||||
|
||||
dacs_t *myDac=malloc(NDAC*sizeof(dacs_t));
|
||||
dacs_t *myAdc=malloc(NADC*sizeof(dacs_t));
|
||||
|
||||
int retval, n;
|
||||
int ret=OK;
|
||||
int dr;//, ow;
|
||||
@ -1431,8 +1435,8 @@ int get_module(int file_des) {
|
||||
sls_detector_module myModule;
|
||||
int *myChip=malloc(NCHIP*sizeof(int));
|
||||
int *myChan=malloc(NCHIP*NCHAN*sizeof(int));
|
||||
float *myDac=malloc(NDAC*sizeof(int));
|
||||
float *myAdc=malloc(NADC*sizeof(int));
|
||||
dacs_t *myDac=malloc(NDAC*sizeof(dacs_t));
|
||||
dacs_t *myAdc=malloc(NADC*sizeof(dacs_t));
|
||||
|
||||
|
||||
if (myDac)
|
||||
|
Loading…
x
Reference in New Issue
Block a user