From 5407fdcf6efb91fe4c3d9f22eb92b98d80b29f70 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Wed, 15 Aug 2012 17:07:55 +0000 Subject: [PATCH] changed dacs and adcs values to be an int between sockets git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@222 951219d9-93cf-4727-9268-0efd64621fa3 --- .../gotthardDetectorServer/Makefile | 2 +- .../communication_funcs.c | 29 +++++++++--------- .../gotthardDetectorServer/firmware_funcs.c | 6 ++-- .../gotthardDetectorServer/firmware_funcs.h | 2 +- .../gotthardDetectorServer/mcb_funcs.c | 30 +++++++++---------- .../gotthardDetectorServer/mcb_funcs.h | 8 ++--- .../gotthardDetectorServer/server_funcs.c | 23 +++++++------- 7 files changed, 49 insertions(+), 51 deletions(-) diff --git a/slsDetectorSoftware/gotthardDetectorServer/Makefile b/slsDetectorSoftware/gotthardDetectorServer/Makefile index f5e50cea2..a70e34457 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/Makefile +++ b/slsDetectorSoftware/gotthardDetectorServer/Makefile @@ -5,7 +5,7 @@ CROSS = bfin-uclinux- CC = $(CROSS)gcc -CFLAGS += -Wall -DMCB_FUNCS -DDACS_DOUBLE #-DVERBOSE -DVERYVERBOSE #-DVIRTUAL +CFLAGS += -Wall -DMCB_FUNCS -DDACS_INT #-DVERBOSE -DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER PROGS= gotthardDetectorServer diff --git a/slsDetectorSoftware/gotthardDetectorServer/communication_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/communication_funcs.c index 200fc0ca9..54ad1c8a2 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/communication_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/communication_funcs.c @@ -291,13 +291,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 @@ -361,8 +361,8 @@ 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; @@ -424,27 +424,26 @@ int receiveModule(int file_des, sls_detector_module* myMod) { printf("dacs received\n"); #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; } -// printf("ndacdiff\t11vref_ds:%f\n",myMod->dacs[0]);printf("11vin_cm:%f\n",myMod->dacs[5]); -/* if (nadcdiff<=0) { + if (nadcdiff<=0) { 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; - } *///printf("nadcdiff\t22vref_ds:%f\n",myMod->dacs[0]);printf("22vin_cm:%f\n",myMod->dacs[5]); + } if (nchipdiff<=0) { ts+=receiveDataOnly(file_des,myMod->chipregs, sizeof(int)*nChips); #ifdef VERBOSE @@ -457,7 +456,7 @@ int receiveModule(int file_des, sls_detector_module* myMod) { ts+=receiveDataOnly(file_des,chipptr, sizeof(int)*nchipdiff); free(chipptr); return FAIL; - }//printf("nchipdiff\t33vref_ds:%f\n",myMod->dacs[0]);printf("33vin_cm:%f\n",myMod->dacs[5]); + } if (nchandiff<=0) { ts+=receiveDataOnly(file_des,myMod->chanregs, sizeof(int)*nChans); #ifdef VERBOSE @@ -470,7 +469,7 @@ int receiveModule(int file_des, sls_detector_module* myMod) { ts+=receiveDataOnly(file_des,chanptr, sizeof(int)*nchandiff); free(chanptr); return FAIL; - }//printf("nchandiff\t44vref_ds:%f\n",myMod->dacs[0]);printf("44vin_cm:%f\n",myMod->dacs[5]); + } #ifdef VERBOSE printf("received module %d of size %d register %x\n",myMod->module,ts,myMod->reg); #endif diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c index 9dbf06111..89ba4a1bc 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c @@ -1213,8 +1213,8 @@ int setDACRegister(int idac, int val, int imod) { } -double getTemperature(int tempSensor, int imod){ - double val; +int getTemperature(int tempSensor, int imod){ + int val; char cTempSensor[2][100]={"ADCs/ASICs","VRs/FPGAs"}; imod=0;//ignoring more than 1 mod for now int i,j,repeats=6; @@ -1241,7 +1241,7 @@ double getTemperature(int tempSensor, int imod){ } bus_w(TEMP_IN_REG,(T1_CLK_BIT)|(T1_CS_BIT)|(T2_CLK_BIT)|(T2_CS_BIT));//standby - val=((double)tempVal)/4.0; + val=((int)tempVal)/4.0; #ifdef VERBOSE printf("Temperature of module:%d for the %s is %.2fC\n",imod,cTempSensor[tempSensor],val); diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h index 180783b33..1487343bc 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h @@ -56,7 +56,7 @@ int setContinousReadOut(int d); int setDACRegister(int idac, int val, int imod); -double getTemperature(int tempSensor,int imod); +int getTemperature(int tempSensor,int imod); int initHighVoltage(int val,int imod); int initConfGain(int isettings,int val,int imod); diff --git a/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c index 9f09e8a69..64db2a006 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/mcb_funcs.c @@ -37,8 +37,8 @@ const int noneSelected=-1; sls_detector_module *detectorModules=NULL; int *detectorChips=NULL; int *detectorChans=NULL; -double *detectorDacs=NULL; -double *detectorAdcs=NULL; +int *detectorDacs=NULL; +int *detectorAdcs=NULL; //int numberOfProbes; @@ -56,8 +56,8 @@ int initDetector() { detectorModules=malloc(n*sizeof(sls_detector_module)); detectorChips=malloc(n*NCHIP*sizeof(int)); detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int)); - detectorDacs=malloc(n*NDAC*sizeof(double)); - detectorAdcs=malloc(n*NADC*sizeof(double)); + detectorDacs=malloc(n*NDAC*sizeof(int)); + detectorAdcs=malloc(n*NADC*sizeof(int)); #ifdef VERBOSE printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n)); printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP)); @@ -540,15 +540,15 @@ int set_one_dac(int imod) { return OK; } -double initDACbyIndex(int ind,double val, int imod) { +int initDACbyIndex(int ind,int val, int imod) { int v; - const double partref[NDAC]=PARTREF; - const double partr1[NDAC]=PARTR1; - const double partr2[NDAC]=PARTR2; + const int partref[NDAC]=PARTREF; + const int partr1[NDAC]=PARTR1; + const int partr2[NDAC]=PARTR2; - double ref=partref[ind]; - double r1=partr1[ind]; - double r2=partr2[ind]; + int ref=partref[ind]; + int r1=partr1[ind]; + int r2=partr2[ind]; v=(val+(val-ref)*r1/r2)*DAC_DR/DAC_MAX; @@ -557,7 +557,7 @@ double initDACbyIndex(int ind,double val, int imod) { return (v*DAC_MAX/DAC_DR+ref*r1/r2)/(1+r1/r2); } -double initDACbyIndexDACU(int ind, int val, int imod) { +int initDACbyIndexDACU(int ind, int val, int imod) { // const double daccs[NDAC]=DACCS; // const double dacaddr[NDAC]=DACADDR; @@ -643,7 +643,7 @@ int getThresholdEnergy() { } #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,(double)(setDACRegister(VREF_DS,-1,imod)));//edited by dhanya + printf("module=%d gain=%f, offset=%f, dacu=%d\n",imod, myg, myo,(int)(setDACRegister(VREF_DS,-1,imod)));//edited by dhanya printf("Threshold energy of module %d is %d eV\n", imod, ethr); #endif @@ -715,7 +715,7 @@ int setThresholdEnergy(int ethr) { -double getDACbyIndexDACU(int ind, int imod) { +int getDACbyIndexDACU(int ind, int imod) { /* if (detectorDacs) { if (imod=getNModBoard()) @@ -997,11 +997,11 @@ int set_dac(int file_des) { #endif #ifdef VERBOSE - printf("DAC set to %f V\n", retval); + printf("DAC set to %d V\n", retval); #endif if(ret==FAIL) - printf("Setting dac %d of module %d: wrote %f but read %f\n", ind, imod, val, retval); + printf("Setting dac %d of module %d: wrote %d but read %d\n", ind, imod, val, retval); else{ if (differentClients) ret=FORCE_UPDATE; @@ -1028,7 +1028,7 @@ int set_dac(int file_des) { int get_adc(int file_des) { //default: mod 0 - double retval; + int retval; int ret=OK; int arg[2]; enum dacIndex ind; @@ -1074,7 +1074,7 @@ int get_adc(int file_des) { #endif #ifdef VERBOSE - printf("ADC is %f V\n", retval); + printf("ADC is %d V\n", retval); #endif if (ret==FAIL) { printf("Getting adc %d of module %d failed\n", ind, imod); @@ -1373,8 +1373,8 @@ int set_module(int file_des) { sls_detector_module myModule; int *myChip=malloc(NCHIP*sizeof(int)); int *myChan=malloc(NCHIP*NCHAN*sizeof(int)); - double *myDac=malloc(NDAC*sizeof(int)); - double *myAdc=malloc(NADC*sizeof(int)); + int *myDac=malloc(NDAC*sizeof(int));/**dhanya*/ + int *myAdc=malloc(NADC*sizeof(int));/**dhanya*/ int retval, n; int ret=OK; int dr;// ow; @@ -1416,7 +1416,6 @@ int set_module(int file_des) { printf("Setting module\n"); #endif ret=receiveModule(file_des, &myModule); - printf("11vref_ds:%f\n",myModule.dacs[0]);printf("11vin_cm:%f\n",myModule.dacs[5]); if (ret>=0) ret=OK; @@ -1492,8 +1491,8 @@ int get_module(int file_des) { sls_detector_module myModule; int *myChip=malloc(NCHIP*sizeof(int)); int *myChan=malloc(NCHIP*NCHAN*sizeof(int)); - double *myDac=malloc(NDAC*sizeof(int)); - double *myAdc=malloc(NADC*sizeof(int)); + int *myDac=malloc(NDAC*sizeof(int));/**dhanya*/ + int *myAdc=malloc(NADC*sizeof(int));/**dhanya*/ if (myDac)