added calibrate pedestal for gotthard

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@456 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2013-02-11 10:45:41 +00:00
parent 2c9f05e8fd
commit 4a4efda69f
11 changed files with 190 additions and 18 deletions

View File

@ -130,8 +130,9 @@ enum {
F_ENABLE_FILE_WRITE, /**< sets the receiver file write */
F_SET_FRAME_INDEX /**< sets the receiver frame index */
F_SET_FRAME_INDEX, /**< sets the receiver frame index */
F_CALIBRATE_PEDESTAL /**< starts acquistion, calibrates pedestal and write back to fpga */
/* Always append functions hereafter!!! */
};

View File

@ -2286,6 +2286,11 @@ int resetCounterBlock(int startACQ){
}
int calibratePedestal(int frames){
printf("In Calibrate Pedestal\n");
return 0;
}

View File

@ -142,6 +142,11 @@ int setSynchronization(int s);
int loadImage(int index, short int ImageVals[]);
int readCounterBlock(int startACQ, short int CounterVals[]);
int resetCounterBlock(int startACQ);
int calibratePedestal(int frames);
/*
u_int32_t setNBits(u_int32_t);

View File

@ -184,6 +184,7 @@ int function_table() {
flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
flist[F_START_RECEIVER]=&start_receiver;
flist[F_STOP_RECEIVER]=&stop_receiver;
flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
return OK;
}
@ -2963,3 +2964,44 @@ int stop_receiver(int file_des) {
int calibrate_pedestal(int file_des){
int ret=OK;
int retval=-1;
int n;
int frames;
sprintf(mess,"Could not calibrate pedestal\n");
n = receiveDataOnly(file_des,&frames,sizeof(frames));
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
ret=FAIL;
}
if (ret==OK) {
if (differentClients==1 && lockStatus==1) {
ret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else
ret=calibratePedestal(frames);
}
if(ret==OK){
if (differentClients)
ret=FORCE_UPDATE;
}
/* send answer */
/* send OK/failed */
n = sendDataOnly(file_des,&ret,sizeof(ret));
if (ret==FAIL)
n += sendDataOnly(file_des,mess,sizeof(mess));
else
n += sendDataOnly(file_des,&retval,sizeof(retval));
/*return ok/fail*/
return ret;
}

View File

@ -90,4 +90,7 @@ int reset_counter_block(int);
int start_receiver(int);
int stop_receiver(int);
int calibrate_pedestal(int);
#endif

View File

@ -1575,8 +1575,12 @@ int multiSlsDetector::setROI(int nroi, int *xmin, int *xmax, int *ymin, int *yma
};
*/
int multiSlsDetector::getROI(int nroi, int *xmin, int *xmax, int *ymin, int *ymax){
};
*/
double* multiSlsDetector::decodeData(int *datain, double *fdata) {
double *dataout;
@ -3921,3 +3925,23 @@ int64_t multiSlsDetector::clearAllErrorMask(){
return getErrorMask();
}
int multiSlsDetector::calibratePedestal(int frames){
int ret=-100, ret1;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) {
ret1=detectors[idet]->calibratePedestal(frames);
if (ret==-100)
ret=ret1;
else if (ret!=ret1)
ret=-1;
}
}
return ret;
}

View File

@ -622,12 +622,25 @@ class multiSlsDetector : public slsDetectorUtils {
/**
set roi
not yet implemented
\param nroi number of rois
\param xmin x minimum of roi
\param xmax x maximum of roi
\param ymin y minimum of roi
\param ymax y maximum of roi
\returns number of rois added
*/
int setROI(int nroi=-1, int *xmin=NULL, int *xmax=NULL, int *ymin=NULL, int *ymax=NULL);
//int setROI(int nroi=-1, int *xmin=NULL, int *xmax=NULL, int *ymin=NULL, int *ymax=NULL);
/**
get roi
\param nroi number of rois
\param xmin x minimum of roi
\param xmax x maximum of roi
\param ymin y minimum of roi
\param ymax y maximum of roi
\returns number of rois
*/
//int getROI(int &xmin, int &xmax, int &ymin, int &ymax);
//Corrections
@ -1146,6 +1159,11 @@ class multiSlsDetector : public slsDetectorUtils {
*/
int64_t clearAllErrorMask();
/** Starts acquisition, calibrates pedestal and writes to fpga
/returns number of frames
*/
int calibratePedestal(int frames = 0);
protected:

View File

@ -3911,11 +3911,19 @@ int slsDetector::setDynamicRange(int n){
return thisDetector->dynamicRange;
};
/*
/*
int slsDetector::setROI(int nroi, int *xmin, int *xmax, int *ymin, int *ymax){
return thisDetector->nROI;
};
int slsDetector::getROI(int nroi, int *xmin, int *xmax, int *ymin, int *ymax){
return thisDetector->nROI;
};
*/
@ -6146,4 +6154,37 @@ int slsDetector::setFrameIndex(int index){
}
int slsDetector::calibratePedestal(int frames){
int ret=FAIL;
int retval=-1;
int fnum=F_CALIBRATE_PEDESTAL;
char mess[100];
#ifdef VERBOSE
std::cout<<"Calibrating Pedestal " <<std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (controlSocket) {
if (controlSocket->Connect()>=0) {
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&frames,sizeof(frames));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret!=FAIL)
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
else {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
}
return retval;
}

View File

@ -1038,16 +1038,18 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int getDataBytes(){return thisDetector->dataBytes;};
/**
set roi
not yet implemented
\param nroi number of rois
\param xmin x minimum of roi
\param xmax x maximum of roi
\param ymin y minimum of roi
\param ymax y maximum of roi
\returns number of rois added
*/
int setROI(int nroi=-1, int *xmin=NULL, int *xmax=NULL, int *ymin=NULL, int *ymax=NULL);
//int setROI(int nroi=-1, int *xmin=NULL, int *xmax=NULL, int *ymin=NULL, int *ymax=NULL);
/**
set/get readout flags
@ -1523,6 +1525,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int fillModuleMask(int *mM);
/** Starts acquisition, calibrates pedestal and writes to fpga
/returns number of frames
*/
int calibratePedestal(int frames = 0);
protected:

View File

@ -383,6 +383,9 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize;
i++;
//descrToFuncMap[i].m_pFuncName="roi"; //
//descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDetectorSize;
//i++;
/* flags */
@ -461,6 +464,13 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
i++;
descrToFuncMap[i].m_pFuncName="pedestal"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSettings;
i++;
/* pots */
descrToFuncMap[i].m_pFuncName="vthreshold"; //
@ -2543,7 +2553,9 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
if (action==PUT_ACTION) {
if (cmd=="maxmod")
return string("cannot put!");
// else if (cmd=="roi"){
// } else
if (sscanf(args[1],"%d",&val))
;
else
@ -2594,11 +2606,9 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
return helpSettings(narg,args,action);
int val=-1;//ret,
char ans[1000];
// portType index;
// if (sscanf(args[1],"%d",&val))
// ;
// else
@ -2672,6 +2682,15 @@ string slsDetectorCommand::cmdSettings(int narg, char *args[], int action) {
myDet->saveSettingsFile(sval, -1);
return string("done");
} else if (cmd=="pedestal") {
if (action==GET_ACTION)
return string("cannot get");
if (sscanf(args[1],"%d",&val)){
sprintf(ans,"%d",myDet->calibratePedestal(val));
return string(ans);
}else
return string("cannot parse frame number")+cmd;
}
return string("unknown settings command ")+cmd;
@ -2686,6 +2705,8 @@ string slsDetectorCommand::helpSettings(int narg, char *args[], int action) {
os << "threshold eV\n sets the detector threshold in eV"<< std::endl;
os << "trimbits fname\n loads the trimfile fname to the detector. If no extension is specified, the serial number of each module will be attached."<< std::endl;
os << "trim:mode fname\n trims the detector according to mode (can be noise, beam, improve, fix) and saves the resulting trimbits to file fname."<< std::endl;
os << "pedestal i \n starts acquisition for i frames, calculates pedestal and writes back to fpga."<< std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "settings \n gets the settings of the detector"<< std::endl;

View File

@ -650,6 +650,11 @@ virtual int exitReceiver()=0;
virtual int enableWriteToFile(int enable=-1)=0;
/** Starts acquisition, calibrates pedestal and writes to fpga
/returns number of frames
*/
virtual int calibratePedestal(int frames = 0)=0;
protected: