mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 21:37:13 +02:00
got rid of extra servers for eiger, converted to c and it works
This commit is contained in:
@ -513,7 +513,6 @@ int set_one_dac(int imod) {
|
||||
bit=value & (1<<(15-ibit));
|
||||
if (bit) {
|
||||
putout("0000010001000000",imod);
|
||||
putout("0000011001000000",imod);
|
||||
putout("0000010001000000",imod);
|
||||
#ifdef DEBUGOUT
|
||||
fprintf(stdout,"1");
|
||||
@ -551,15 +550,15 @@ int initDACbyIndex(int ind,int val, int imod) {
|
||||
int ref=partref[ind];
|
||||
int r1=partr1[ind];
|
||||
int r2=partr2[ind];
|
||||
|
||||
int retval[2];
|
||||
|
||||
v=(val+(val-ref)*r1/r2)*DAC_DR/DAC_MAX;
|
||||
v=initDACbyIndexDACU(ind,v,imod);
|
||||
v=initDACbyIndexDACU(ind,v,imod,0,retval);
|
||||
|
||||
return (v*DAC_MAX/DAC_DR+ref*r1/r2)/(1+r1/r2);
|
||||
}
|
||||
|
||||
int initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
int initDACbyIndexDACU(int ind, int val, int imod, int mV, int retval[]) {
|
||||
|
||||
// const double daccs[NDAC]=DACCS;
|
||||
// const double dacaddr[NDAC]=DACADDR;
|
||||
@ -568,6 +567,8 @@ int initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
// int addr=dacaddr[ind];
|
||||
// int iv;
|
||||
int im;
|
||||
if(mV)
|
||||
val = (val*4096)/2500;
|
||||
|
||||
if (val>=0)
|
||||
initDAC(ind,val, imod);
|
||||
@ -598,124 +599,12 @@ int initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
#ifdef VERBOSE
|
||||
printf("returning %d\n",setDACRegister(ind, -1, 0));
|
||||
#endif
|
||||
return setDACRegister(ind, -1, 0);
|
||||
retval[0] = setDACRegister(ind, -1, 0);
|
||||
retval[1] = (retval[0]*2500)/4096;
|
||||
return retval[0];
|
||||
}
|
||||
}
|
||||
|
||||
int getThresholdEnergy() {
|
||||
double g[3]=DEFAULTGAIN;
|
||||
double o[3]=DEFAULTOFFSET;
|
||||
double myg=-1, myo=-1;
|
||||
// int dacu;
|
||||
int imod;
|
||||
int ethr=-1;
|
||||
int ret=FAIL;
|
||||
|
||||
if (detectorModules) {
|
||||
// for (imod=0; imod<getNModBoard(); imod++) {
|
||||
for (imod=0; imod<nModX; imod++) {
|
||||
#ifdef VERBOSE
|
||||
printf("module=%d settings=%d, gain=%f, offset=%f\n",imod,thisSettings, (detectorModules+imod)->gain,(detectorModules+imod)->offset);
|
||||
#endif
|
||||
if ((detectorModules+imod)->gain>0)
|
||||
myg=(detectorModules+imod)->gain;
|
||||
else {
|
||||
if (thisSettings>=0 && thisSettings<3)
|
||||
myg=g[thisSettings];
|
||||
// else
|
||||
//myg=-1;
|
||||
}
|
||||
|
||||
if ((detectorModules+imod)->offset>0)
|
||||
myo=(detectorModules+imod)->offset;
|
||||
else {
|
||||
if (thisSettings>=0 && thisSettings<3)
|
||||
myo=o[thisSettings];
|
||||
// else
|
||||
//myo=-1;
|
||||
}
|
||||
|
||||
if (myg>0 && myo>0) {
|
||||
//ethr=(myo-detectorDacs[VTHRESH+imod*NDAC])*1000/myg;
|
||||
|
||||
ethr=(myo-setDACRegister(VDAC0,-1,imod))*1000/myg;//edited by dhanya
|
||||
// else
|
||||
// ethr=-1;
|
||||
|
||||
}
|
||||
#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=%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
|
||||
|
||||
if (imod==0)
|
||||
ret=ethr;
|
||||
else {
|
||||
if (ethr>(ret+100) || ethr<(ret-100))
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int setThresholdEnergy(int ethr) {
|
||||
double g[3]=DEFAULTGAIN;
|
||||
double o[3]=DEFAULTOFFSET;
|
||||
double myg=-1, myo=-1;
|
||||
int dacu;
|
||||
int imod;
|
||||
int ret=ethr;
|
||||
|
||||
setSettings(GET_SETTINGS,-1);//-1 added by dhanya
|
||||
if (thisSettings>=0 || thisSettings<3){
|
||||
myg=g[thisSettings];
|
||||
myo=o[thisSettings];
|
||||
}
|
||||
for (imod=0; imod<nModX; imod++) {
|
||||
if (detectorModules) {
|
||||
if ((detectorModules+imod)->gain>0)
|
||||
myg=(detectorModules+imod)->gain;
|
||||
else
|
||||
if (thisSettings>=0 && thisSettings<3)
|
||||
myg=g[thisSettings];
|
||||
else
|
||||
myg=-1;
|
||||
if ((detectorModules+imod)->offset>0)
|
||||
myo=(detectorModules+imod)->offset;
|
||||
else
|
||||
if (thisSettings>=0 && thisSettings<3)
|
||||
myo=o[thisSettings];
|
||||
else
|
||||
myo=-1;
|
||||
} else {
|
||||
if (thisSettings>=0 && thisSettings<3)
|
||||
myo=o[thisSettings];
|
||||
else
|
||||
myo=-1;
|
||||
if (thisSettings>=0 && thisSettings<3)
|
||||
myg=g[thisSettings];
|
||||
else
|
||||
myg=-1;
|
||||
}
|
||||
if (myg>0 && myo>0) {
|
||||
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
|
||||
} else {
|
||||
dacu=ethr;
|
||||
#ifdef VERBOSE
|
||||
printf("could not set threshold energy for module %d, settings %d (offset is %f; gain is %f)\n",imod,thisSettings,myo,myg);
|
||||
#endif
|
||||
}
|
||||
initDACbyIndexDACU(VDAC0, dacu, imod); ///needs to be fixed dhanya
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int getDACbyIndexDACU(int ind, int imod) {
|
||||
/*
|
||||
@ -2585,19 +2474,9 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
|
||||
|
||||
int i,adc;
|
||||
ROI temp;
|
||||
|
||||
/*
|
||||
if(n>=0){
|
||||
|
||||
//clear rois
|
||||
for(i=0;i<MAX_ROIS;i++)
|
||||
rois[i]=temp;
|
||||
|
||||
/*ideal way to set roi
|
||||
for(i=0;i<n;i++)
|
||||
rois[i]=arg[i];
|
||||
nROI = n;
|
||||
*/
|
||||
|
||||
if(n==0)
|
||||
adc=-1;
|
||||
else{
|
||||
@ -2633,7 +2512,7 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret){
|
||||
|
||||
//set adc of interest
|
||||
setADC(adc);
|
||||
}
|
||||
}*/
|
||||
|
||||
//#ifdef VERBOSE
|
||||
printf("Rois:\n");
|
||||
|
Reference in New Issue
Block a user