mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
Changed everywhere from float to double, even mythenDetectorServer and the standalone files
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@206 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -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(float)*nDacs);
|
||||
ts+= sendDataOnly(file_des,myMod->dacs,sizeof(double)*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(float)*nAdcs);
|
||||
ts+= sendDataOnly(file_des,myMod->adcs,sizeof(double)*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) {
|
||||
|
||||
|
||||
float *dacptr=myMod->dacs;
|
||||
float *adcptr=myMod->adcs;
|
||||
double *dacptr=myMod->dacs;
|
||||
double *adcptr=myMod->adcs;
|
||||
int *chipptr=myMod->chipregs, *chanptr=myMod->chanregs;
|
||||
int ts=0;
|
||||
int nChips, nchipold=myMod->nchip, nchipdiff;
|
||||
@ -419,29 +419,29 @@ 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(float)*nDacs);
|
||||
ts+=receiveDataOnly(file_des,myMod->dacs, sizeof(double)*nDacs);
|
||||
#ifdef VERBOSE
|
||||
printf("dacs received\n");
|
||||
#endif
|
||||
} else {
|
||||
dacptr=malloc(ndacdiff*sizeof(float));
|
||||
dacptr=malloc(ndacdiff*sizeof(double));
|
||||
myMod->ndac=ndold;
|
||||
ts+=receiveDataOnly(file_des,myMod->dacs, sizeof(float)*ndold);
|
||||
ts+=receiveDataOnly(file_des,dacptr, sizeof(float)*ndacdiff);
|
||||
ts+=receiveDataOnly(file_des,myMod->dacs, sizeof(double)*ndold);
|
||||
ts+=receiveDataOnly(file_des,dacptr, sizeof(double)*ndacdiff);
|
||||
free(dacptr);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (nadcdiff<=0) {
|
||||
ts+=receiveDataOnly(file_des,myMod->adcs, sizeof(float)*nAdcs);
|
||||
ts+=receiveDataOnly(file_des,myMod->adcs, sizeof(double)*nAdcs);
|
||||
#ifdef VERBOSE
|
||||
printf("adcs received\n");
|
||||
#endif
|
||||
} else {
|
||||
adcptr=malloc(nadcdiff*sizeof(float));
|
||||
adcptr=malloc(nadcdiff*sizeof(double));
|
||||
myMod->nadc=naold;
|
||||
ts+=receiveDataOnly(file_des,myMod->adcs, sizeof(float)*naold);
|
||||
ts+=receiveDataOnly(file_des,adcptr, sizeof(float)*nadcdiff);
|
||||
ts+=receiveDataOnly(file_des,myMod->adcs, sizeof(double)*naold);
|
||||
ts+=receiveDataOnly(file_des,adcptr, sizeof(double)*nadcdiff);
|
||||
free(adcptr);
|
||||
return FAIL;
|
||||
}
|
||||
|
@ -1208,8 +1208,8 @@ int setDACRegister(int idac, int val, int imod) {
|
||||
}
|
||||
|
||||
|
||||
float getTemperature(int tempSensor, int imod){
|
||||
float val;
|
||||
double getTemperature(int tempSensor, int imod){
|
||||
double val;
|
||||
char cTempSensor[2][100]={"ADCs/ASICs","VRs/FPGAs"};
|
||||
imod=0;//ignoring more than 1 mod for now
|
||||
int i,j,repeats=6;
|
||||
@ -1236,7 +1236,7 @@ float getTemperature(int tempSensor, int imod){
|
||||
}
|
||||
|
||||
bus_w(TEMP_IN_REG,(T1_CLK_BIT)|(T1_CS_BIT)|(T2_CLK_BIT)|(T2_CS_BIT));//standby
|
||||
val=((float)tempVal)/4.0;
|
||||
val=((double)tempVal)/4.0;
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Temperature of module:%d for the %s is %.2fC\n",imod,cTempSensor[tempSensor],val);
|
||||
|
@ -56,7 +56,7 @@ int setContinousReadOut(int d);
|
||||
|
||||
int setDACRegister(int idac, int val, int imod);
|
||||
|
||||
float getTemperature(int tempSensor,int imod);
|
||||
double getTemperature(int tempSensor,int imod);
|
||||
int initHighVoltage(int val,int imod);
|
||||
int initConfGain(int isettings,int val,int imod);
|
||||
|
||||
|
@ -37,8 +37,8 @@ const int noneSelected=-1;
|
||||
sls_detector_module *detectorModules=NULL;
|
||||
int *detectorChips=NULL;
|
||||
int *detectorChans=NULL;
|
||||
float *detectorDacs=NULL;
|
||||
float *detectorAdcs=NULL;
|
||||
double *detectorDacs=NULL;
|
||||
double *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(float));
|
||||
detectorAdcs=malloc(n*NADC*sizeof(float));
|
||||
detectorDacs=malloc(n*NDAC*sizeof(double));
|
||||
detectorAdcs=malloc(n*NADC*sizeof(double));
|
||||
#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;
|
||||
}
|
||||
|
||||
float initDACbyIndex(int ind,float val, int imod) {
|
||||
double initDACbyIndex(int ind,double val, int imod) {
|
||||
int v;
|
||||
const float partref[NDAC]=PARTREF;
|
||||
const float partr1[NDAC]=PARTR1;
|
||||
const float partr2[NDAC]=PARTR2;
|
||||
const double partref[NDAC]=PARTREF;
|
||||
const double partr1[NDAC]=PARTR1;
|
||||
const double partr2[NDAC]=PARTR2;
|
||||
|
||||
float ref=partref[ind];
|
||||
float r1=partr1[ind];
|
||||
float r2=partr2[ind];
|
||||
double ref=partref[ind];
|
||||
double r1=partr1[ind];
|
||||
double r2=partr2[ind];
|
||||
|
||||
|
||||
v=(val+(val-ref)*r1/r2)*DAC_DR/DAC_MAX;
|
||||
@ -557,10 +557,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) {
|
||||
double initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
|
||||
// const float daccs[NDAC]=DACCS;
|
||||
// const float dacaddr[NDAC]=DACADDR;
|
||||
// const double daccs[NDAC]=DACCS;
|
||||
// const double dacaddr[NDAC]=DACADDR;
|
||||
|
||||
// int cs=daccs[ind];
|
||||
// int addr=dacaddr[ind];
|
||||
@ -601,9 +601,9 @@ float initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
}
|
||||
|
||||
int getThresholdEnergy() {
|
||||
float g[3]=DEFAULTGAIN;
|
||||
float o[3]=DEFAULTOFFSET;
|
||||
float myg=-1, myo=-1;
|
||||
double g[3]=DEFAULTGAIN;
|
||||
double o[3]=DEFAULTOFFSET;
|
||||
double myg=-1, myo=-1;
|
||||
// int dacu;
|
||||
int imod;
|
||||
int ethr=-1;
|
||||
@ -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,(float)(setDACRegister(VREF_DS,-1,imod)));//edited by dhanya
|
||||
printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo,(double)(setDACRegister(VREF_DS,-1,imod)));//edited by dhanya
|
||||
printf("Threshold energy of module %d is %d eV\n", imod, ethr);
|
||||
#endif
|
||||
|
||||
@ -659,9 +659,9 @@ int getThresholdEnergy() {
|
||||
}
|
||||
|
||||
int setThresholdEnergy(int ethr) {
|
||||
float g[3]=DEFAULTGAIN;
|
||||
float o[3]=DEFAULTOFFSET;
|
||||
float myg=-1, myo=-1;
|
||||
double g[3]=DEFAULTGAIN;
|
||||
double o[3]=DEFAULTOFFSET;
|
||||
double myg=-1, myo=-1;
|
||||
int dacu;
|
||||
int imod;
|
||||
int ret=ethr;
|
||||
@ -698,7 +698,7 @@ int setThresholdEnergy(int ethr) {
|
||||
myg=-1;
|
||||
}
|
||||
if (myg>0 && myo>0) {
|
||||
dacu=myo-myg*((float)ethr)/1000.;
|
||||
dacu=myo-myg*((double)ethr)/1000.;
|
||||
#ifdef VERBOSE
|
||||
printf("module %d (%x): gain %f, off %f, energy %d eV, dac %d\n",imod,(unsigned int)((detectorModules+imod)),(detectorModules+imod)->gain,(detectorModules+imod)->offset, ethr,dacu);
|
||||
#endif
|
||||
@ -715,7 +715,7 @@ int setThresholdEnergy(int ethr) {
|
||||
|
||||
|
||||
|
||||
float getDACbyIndexDACU(int ind, int imod) {
|
||||
double getDACbyIndexDACU(int ind, int imod) {
|
||||
/*
|
||||
if (detectorDacs) {
|
||||
if (imod<getNModBoard())
|
||||
@ -741,7 +741,7 @@ int initDAC(int dac_addr, int value, int imod) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float getTemperatureByModule(int tempSensor, int imod)
|
||||
double getTemperatureByModule(int tempSensor, int imod)
|
||||
{
|
||||
int im;
|
||||
//for the particular module
|
||||
|
@ -108,14 +108,14 @@ int set_one_dac(int imod);
|
||||
int initDAC(int dac_addr, int value,int imod );
|
||||
int initDACs(int* v,int imod );
|
||||
int setSettings(int i,int imod);
|
||||
float initDACbyIndex(int ind,float val, int imod);
|
||||
float initDACbyIndexDACU(int ind,int val, int imod);
|
||||
float getDACbyIndexDACU(int ind, int imod);
|
||||
double initDACbyIndex(int ind,double val, int imod);
|
||||
double initDACbyIndexDACU(int ind,int val, int imod);
|
||||
double getDACbyIndexDACU(int ind, int imod);
|
||||
int getThresholdEnergy();
|
||||
int setThresholdEnergy(int ethr);
|
||||
|
||||
/* Other DAC index routines*/
|
||||
float getTemperatureByModule(int tempSensor, int imod);
|
||||
double getTemperatureByModule(int tempSensor, int imod);
|
||||
int initHighVoltageByModule(int val, int imod);
|
||||
int initConfGainByModule(int isettings,int val,int imod);
|
||||
|
||||
|
@ -899,13 +899,13 @@ int read_register(int file_des) {
|
||||
|
||||
int set_dac(int file_des) {
|
||||
//default:all mods
|
||||
float retval;
|
||||
double retval;
|
||||
int ret=OK;
|
||||
int arg[2];
|
||||
enum dacIndex ind;
|
||||
int imod;
|
||||
int n;
|
||||
float val;
|
||||
double val;
|
||||
int idac=0;
|
||||
|
||||
sprintf(mess,"Can't set DAC\n");
|
||||
@ -1028,7 +1028,7 @@ int set_dac(int file_des) {
|
||||
|
||||
int get_adc(int file_des) {
|
||||
//default: mod 0
|
||||
float retval;
|
||||
double retval;
|
||||
int ret=OK;
|
||||
int arg[2];
|
||||
enum dacIndex ind;
|
||||
@ -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));
|
||||
float *myDac=malloc(NDAC*sizeof(int));
|
||||
float *myAdc=malloc(NADC*sizeof(int));
|
||||
double *myDac=malloc(NDAC*sizeof(int));
|
||||
double *myAdc=malloc(NADC*sizeof(int));
|
||||
int retval, n;
|
||||
int ret=OK;
|
||||
int dr;// ow;
|
||||
@ -1492,8 +1492,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));
|
||||
double *myDac=malloc(NDAC*sizeof(int));
|
||||
double *myAdc=malloc(NADC*sizeof(int));
|
||||
|
||||
|
||||
if (myDac)
|
||||
|
@ -161,11 +161,11 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
|
||||
|
||||
int *fifodata;
|
||||
|
||||
float vthreshmean, vthreshSTDev;
|
||||
double vthreshmean, vthreshSTDev;
|
||||
int *thrmi, *thrma;
|
||||
float c;
|
||||
float b=BVTRIM;
|
||||
float a=AVTRIM;
|
||||
double c;
|
||||
double b=BVTRIM;
|
||||
double a=AVTRIM;
|
||||
int *trim;
|
||||
int ich, imod, ichan;
|
||||
int nvalid=0;
|
||||
@ -439,7 +439,7 @@ int trim_with_level(int countlim, int im) {
|
||||
int kth_smallest(int *a, int n, int k)
|
||||
{
|
||||
register int i,j,l,m ;
|
||||
register float x ;
|
||||
register double x ;
|
||||
|
||||
l=0 ; m=n-1 ;
|
||||
while (l<m) {
|
||||
@ -466,7 +466,7 @@ int ave(int *a, int n)
|
||||
{
|
||||
int av=0,i;
|
||||
for (i=0; i<n; i++)
|
||||
av=av+((float)*(a+i))/((float)n);
|
||||
av=av+((double)*(a+i))/((double)n);
|
||||
return av;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user