changed all the dacs and adc types from double to dacs_int to an ifdef defined in sls det defs

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@223 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2012-08-15 17:12:20 +00:00
parent 5407fdcf6e
commit 3e8f1e22e9
9 changed files with 56 additions and 39 deletions

View File

@ -1,5 +1,5 @@
CFLAGS= -DC_ONLY
#FLAGS= -DVERBOSE -DVERYVERBOSE
FLAGS= -DVERBOSE -DVERYVERBOSE -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

View File

@ -17,6 +17,15 @@ typedef int int32_t;
typedef char mystring[MAX_STR_LENGTH];
typedef double mysteps[MAX_SCAN_STEPS];
#ifdef DACS_INT
typedef int dacs_t;
//typedef uint32_t dacs_t;
//#elif DACS_INT_CSERVER
//typedef u_int32_t dacs_t;
#else
typedef float dacs_t;
#endif
/**
\file sls_detector_defs.h
This file contains all the basic definitions common to the slsDetector class
@ -102,8 +111,8 @@ typedef struct {
int nadc; /**< is the number of adcs on the module */
int reg; /**< is the module register (e.g. dynamic range?)
\see moduleRegisterBit */
double *dacs; /**< is the pointer to the array of the dac values (in V) */
double *adcs; /**< is the pointer to the array of the adc values (in V) FLAT_FIELD_CORRECTION*/
dacs_t *dacs; /**< is the pointer to the array of the dac values (in V) */
dacs_t *adcs; /**< is the pointer to the array of the adc values (in V) FLAT_FIELD_CORRECTION*/
int *chipregs; /**< is the pointer to the array of the chip registers
\see ::chipRegisterBit */
int *chanregs; /**< is the pointer to the array of the channel registers

View File

@ -2157,8 +2157,8 @@ int multiSlsDetector::getAngularConversion(int &direction, angleConversionCons
double multiSlsDetector::setDAC(double val, dacIndex idac, int imod) {
double ret, ret1=-100;
dacs_t multiSlsDetector::setDAC(dacs_t val, dacIndex idac, int imod) {
dacs_t ret, ret1=-100;
int id=-1, im=-1;
int dmi=0, dma=thisMultiDetector->numberOfDetectors;
@ -2180,8 +2180,8 @@ double multiSlsDetector::setDAC(double val, dacIndex idac, int imod) {
return ret1;
}
double multiSlsDetector::getADC(dacIndex idac, int imod) {
double ret, ret1=-100;
dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) {
dacs_t ret, ret1=-100;
int id=-1, im=-1;
int dmi=0, dma=thisMultiDetector->numberOfDetectors;

View File

@ -796,7 +796,7 @@ class multiSlsDetector : public slsDetectorUtils {
\param imod module number (if -1 alla modules)
\returns current DAC value
*/
double setDAC(double val, dacIndex index, int imod=-1);
dacs_t setDAC(dacs_t val, dacIndex index, int imod=-1);
/**
set dacs value
\param val value (in V)
@ -804,7 +804,7 @@ class multiSlsDetector : public slsDetectorUtils {
\param imod module number (if -1 alla modules)
\returns current DAC value
*/
double getADC(dacIndex index, int imod=0);
dacs_t getADC(dacIndex index, int imod=0);
/**
configure channel
\param reg channel register

View File

@ -599,8 +599,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->fferroff=thisDetector->ffoff+sizeof(double)*thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;
thisDetector->modoff= thisDetector->fferroff+sizeof(double)*thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;
thisDetector->dacoff=thisDetector->modoff+sizeof(sls_detector_module)*thisDetector->nModsMax;
thisDetector->adcoff=thisDetector->dacoff+sizeof(double)*thisDetector->nDacs*thisDetector->nModsMax;
thisDetector->chipoff=thisDetector->adcoff+sizeof(double)*thisDetector->nAdcs*thisDetector->nModsMax;
thisDetector->adcoff=thisDetector->dacoff+sizeof(dacs_t)*thisDetector->nDacs*thisDetector->nModsMax;
thisDetector->chipoff=thisDetector->adcoff+sizeof(dacs_t)*thisDetector->nAdcs*thisDetector->nModsMax;
thisDetector->chanoff=thisDetector->chipoff+sizeof(int)*thisDetector->nChips*thisDetector->nModsMax;
@ -615,8 +615,8 @@ int slsDetector::initializeDetectorSize(detectorType type) {
// for (int imod=0; imod< thisDetector->nModsMax; imod++)
// std::cout<< hex << detectorModules+imod << dec <<std::endl;
#endif
dacs=(double*)(goff+thisDetector->dacoff);
adcs=(double*)(goff+thisDetector->adcoff);
dacs=(dacs_t*)(goff+thisDetector->dacoff);
adcs=(dacs_t*)(goff+thisDetector->adcoff);
chipregs=(int*)(goff+thisDetector->chipoff);
chanregs=(int*)(goff+thisDetector->chanoff);
if (thisDetector->alreadyExisting==0) {
@ -775,8 +775,8 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t)
na=0;
}
double *dacs=new double[nd];
double *adcs=new double[na];
dacs_t *dacs=new dacs_t[nd];
dacs_t *adcs=new dacs_t[na];
int *chipregs=new int[nc];
int *chanregs=new int[nch*nc];
myMod->ndac=nd;
@ -825,8 +825,8 @@ int slsDetector::sendChip(sls_detector_chip *myChip) {
int slsDetector::sendModule(sls_detector_module *myMod) {
int ts=0;
ts+=controlSocket->SendDataOnly(myMod,sizeof(sls_detector_module));
ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(double)*(myMod->ndac));
ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(double)*(myMod->nadc));
ts+=controlSocket->SendDataOnly(myMod->dacs,sizeof(dacs_t)*(myMod->ndac));
ts+=controlSocket->SendDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc));
ts+=controlSocket->SendDataOnly(myMod->chipregs,sizeof(int)*(myMod->nchip));
ts+=controlSocket->SendDataOnly(myMod->chanregs,sizeof(int)*(myMod->nchan));
return ts;
@ -856,8 +856,8 @@ int slsDetector::receiveChip(sls_detector_chip* myChip) {
int slsDetector::receiveModule(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;
int *chanptr=myMod->chanregs;
int ts=0;
@ -870,11 +870,11 @@ int slsDetector::receiveModule(sls_detector_module* myMod) {
#ifdef VERBOSE
std::cout<< "received module " << myMod->module << " of size "<< ts << " register " << myMod->reg << std::endl;
#endif
ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(double)*(myMod->ndac));
ts+=controlSocket->ReceiveDataOnly(myMod->dacs,sizeof(dacs_t)*(myMod->ndac));
#ifdef VERBOSE
std::cout<< "received dacs " << myMod->module << " of size "<< ts << std::endl;
#endif
ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(double)*(myMod->nadc));
ts+=controlSocket->ReceiveDataOnly(myMod->adcs,sizeof(dacs_t)*(myMod->nadc));
#ifdef VERBOSE
std::cout<< "received adcs " << myMod->module << " of size "<< ts << std::endl;
#endif
@ -1810,11 +1810,10 @@ int slsDetector::readRegister(int addr){
}{};
*/
double slsDetector::setDAC(double val, dacIndex index, int imod){
dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int imod){
double retval;
dacs_t retval;
int fnum=F_SET_DAC;
int ret=FAIL;
char mess[100];
@ -1868,9 +1867,9 @@ double slsDetector::setDAC(double val, dacIndex index, int imod){
};
double slsDetector::getADC(dacIndex index, int imod){
dacs_t slsDetector::getADC(dacIndex index, int imod){
double retval;
dacs_t retval;
int fnum=F_GET_ADC;
int ret=FAIL;
char mess[100];
@ -2272,7 +2271,7 @@ int slsDetector::setModule(int reg, int imod){
#endif
int charegs[thisDetector->nChans*thisDetector->nChips];
int chiregs[thisDetector->nChips];
double das[thisDetector->nDacs], ads[thisDetector->nAdcs];
dacs_t das[thisDetector->nDacs], ads[thisDetector->nAdcs];
int mmin=imod, mmax=imod+1;
int ret=FAIL;
@ -2345,7 +2344,6 @@ int slsDetector::setModule(int reg, int imod){
int slsDetector::setModule(sls_detector_module module){
int fnum=F_SET_MODULE;
int retval;
int ret=FAIL;

View File

@ -727,7 +727,7 @@ typedef struct sharedSlsDetector {
\param imod module number (if -1 alla modules)
\returns current DAC value
*/
double setDAC(double val, dacIndex index, int imod=-1);
dacs_t setDAC(dacs_t val, dacIndex index, int imod=-1);
/**
set dacs value
@ -735,7 +735,7 @@ typedef struct sharedSlsDetector {
\param imod module number
\returns current ADC value
*/
double getADC(dacIndex index, int imod=0);
dacs_t getADC(dacIndex index, int imod=0);
/**
configure channel
@ -1374,9 +1374,9 @@ typedef struct sharedSlsDetector {
/** pointer to detector module structures */
sls_detector_module *detectorModules;
/** pointer to dac valuse */
double *dacs;
dacs_t *dacs;
/** pointer to adc valuse */
double *adcs;
dacs_t *adcs;
/** pointer to chip registers */
int *chipregs;
/** pointer to channal registers */

View File

@ -191,7 +191,7 @@ class slsDetectorActions : public virtual slsDetectorBase
\param imod module number (if -1 alla modules)
\returns current DAC value
*/
virtual double setDAC(double val, dacIndex index , int imod=-1)=0;
virtual dacs_t setDAC(dacs_t val, dacIndex index , int imod=-1)=0;
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;

View File

@ -2638,7 +2638,7 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) {
return helpDAC(narg, args, action);
dacIndex dac;
double val=-1;
dacs_t val=-1;
char answer[1000];
if (cmd=="vthreshold")
@ -2691,15 +2691,22 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) {
return string("cannot decode dac ")+cmd;
if (action==PUT_ACTION) {
if (sscanf(args[1],"%lf", &val))
#ifdef DACS_INT
if (sscanf(args[1],"%d", &val))
#else
if (sscanf(args[1],"%f", &val))
#endif
;
else
return string("cannot scan DAC value ")+string(args[1]);
}
myDet->setOnline(ONLINE_FLAG);
#ifdef DACS_INT
sprintf(answer,"%d",myDet->setDAC(val,dac));
#else
sprintf(answer,"%f",myDet->setDAC(val,dac));
#endif
return string(answer);
}
@ -2804,8 +2811,11 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) {
return string("cannot decode adc ")+cmd;
myDet->setOnline(ONLINE_FLAG);
#ifdef DACS_INT
sprintf(answer,"%d",myDet->getADC(adc));
#else
sprintf(answer,"%f",myDet->getADC(adc));
#endif
return string(answer);
}

View File

@ -500,7 +500,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param imod module number (if -1 alla modules)
\returns current DAC value
*/
virtual double setDAC(double val, dacIndex index , int imod=-1)=0;
virtual dacs_t setDAC(dacs_t val, dacIndex index , int imod=-1)=0;
/**
@ -509,7 +509,7 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
\param imod module number
\returns current ADC value
*/
virtual double getADC(dacIndex index, int imod=0)=0;
virtual dacs_t getADC(dacIndex index, int imod=0)=0;
/**
get the maximum size of the detector