changes for new chipterboard -now works with reduced dynamic range and analog/digital readout

This commit is contained in:
2016-11-09 11:36:59 +01:00
parent 988426dc96
commit cb879c61ca
22 changed files with 896 additions and 341 deletions

View File

@ -24,7 +24,7 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
int sz;
//shmId=-1;
cout << "init shm"<< endl;
switch(type) {
case MYTHEN:
nch=128; // complete mythen system
@ -81,7 +81,7 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
no=0;
break;
case JUNGFRAUCTB:
nch=32;
nch=36; //36? is using digital value as well
nm=1; //modules/detector
nc=1; //chips
nd=16; //dacs+adcs
@ -242,6 +242,7 @@ slsDetector::slsDetector(detectorType type, int id,multiSlsDetector *p): slsDete
/**Initializes the detector stucture \sa initializeDetectorSize
*/
cout << "init det size"<< endl;
initializeDetectorSize(type);
@ -634,12 +635,12 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->dynamicRange=16;
break;
case JUNGFRAUCTB:
thisDetector->nChan[X]=32;
thisDetector->nChan[X]=36;
thisDetector->nChan[Y]=1;
thisDetector->nChip[X]=1;
thisDetector->nChip[Y]=1;
thisDetector->nDacs=16;
thisDetector->nAdcs=1;
thisDetector->nAdcs=9;
thisDetector->nGain=0;
thisDetector->nOffset=0;
thisDetector->nModMax[X]=1;
@ -684,12 +685,14 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->timerValue[FRAME_NUMBER]=1;
thisDetector->timerValue[MEASUREMENTS_NUMBER]=1;
thisDetector->timerValue[CYCLES_NUMBER]=1;
thisDetector->timerValue[SAMPLES_JCTB]=1;
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*thisDetector->dynamicRange/8;
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->dynamicRange/8;
cout << "here1" << endl;
getTotalNumberOfChannels();
// thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
}
if(thisDetector->myDetectorType==MYTHEN){
if (thisDetector->dynamicRange==24 || thisDetector->timerValue[PROBES_NUMBER]>0)
@ -789,6 +792,15 @@ int slsDetector::initializeDetectorSize(detectorType type) {
//update?!?!?!?
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
cout << "here2" << endl;
getTotalNumberOfChannels();
//thisDetector->nChan[X]=32;
//thisDetector->nChans=thisDetector->nChan[X]*thisDetector->nChan[Y];
//thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
}
}
@ -1012,7 +1024,7 @@ slsDetectorDefs::sls_detector_module* slsDetector::createModule(detectorType t)
na=0;
break;
case JUNGFRAUCTB:
nch=32;//32;
nch=36;
nm=1;
nc=1;
nd=8; // dacs+adcs
@ -1621,8 +1633,56 @@ slsDetectorDefs::detectorType slsDetector::getDetectorsType(int pos){
}
// /** number of rois defined */
// int nROI;
// /** list of rois */
// ROI roiLimits[MAX_ROIS];
// /** readout flags */
// readOutFlags roFlags;
int slsDetector::getTotalNumberOfChannels() {
cout << "total number of channels" << endl;
if(thisDetector->myDetectorType==JUNGFRAUCTB){
if (thisDetector->roFlags&DIGITAL_ONLY)
thisDetector->nChan[X]=4;
else if (thisDetector->roFlags&ANALOG_AND_DIGITAL)
thisDetector->nChan[X]=36;
else
thisDetector->nChan[X]=32;
if (thisDetector->nChan[X]>=32) {
if (thisDetector->nROI>0) {
thisDetector->nChan[X]-=32;
for (int iroi=0; iroi<thisDetector->nROI; iroi++)
thisDetector->nChan[X]+=thisDetector->roiLimits[iroi].xmax-thisDetector->roiLimits[iroi].xmin+1;
}
}
thisDetector->nChans=thisDetector->nChan[X];
thisDetector->dataBytes=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods*2*thisDetector->timerValue[SAMPLES_JCTB];
cout << "Total number of channels is "<< thisDetector->nChans*thisDetector->nChips*thisDetector->nMods << " data bytes is " << thisDetector->dataBytes << endl;
}
return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;
};
int slsDetector::getTotalNumberOfChannels(dimension d) {
getTotalNumberOfChannels();
return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nMod[d];
};
int slsDetector::getMaxNumberOfChannels(){
if(thisDetector->myDetectorType==JUNGFRAUCTB) return 36*thisDetector->nChips*thisDetector->nModsMax;
return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;
};
int slsDetector::getMaxNumberOfChannels(dimension d){
if(thisDetector->myDetectorType==JUNGFRAUCTB) if (d==X) return 36*thisDetector->nChip[d]*thisDetector->nModMax[d]; else return 1*thisDetector->nChip[d]*thisDetector->nModMax[d];
return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nModMax[d];
};
/* needed to set/get the size of the detector */
// if n=GET_FLAG returns the number of installed modules,
int slsDetector::setNumberOfModules(int n, dimension d){
@ -1699,14 +1759,6 @@ int slsDetector::setNumberOfModules(int n, dimension d){
if (thisDetector->nModMax[Y]<thisDetector->nMod[Y])
thisDetector->nModMax[Y]=thisDetector->nMod[Y];
int dr=thisDetector->dynamicRange;
if (dr==24)
dr=32;
@ -1719,8 +1771,8 @@ int slsDetector::setNumberOfModules(int n, dimension d){
}
if(thisDetector->myDetectorType==JUNGFRAUCTB){
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*dr/8;
getTotalNumberOfChannels();
//thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->nChans*dr/8*thisDetector->nChips*thisDetector->timerValue[SAMPLES_JCTB];
}
@ -3461,6 +3513,7 @@ int slsDetector::getChanRegs(double* retval,bool fromDetector){
int slsDetector::updateDetectorNoWait() {
enum readOutFlags ro;
// int ret=OK;
enum detectorSettings t;
int thr, n, nm;
@ -3508,7 +3561,7 @@ int slsDetector::updateDetectorNoWait() {
if((thisDetector->myDetectorType!= GOTTHARD)&&
(thisDetector->myDetectorType!= PROPIX)&&
(thisDetector->myDetectorType!= JUNGFRAU)&&
(thisDetector->myDetectorType!= MOENCH)){
(thisDetector->myDetectorType!= MOENCH) && (thisDetector->myDetectorType!= JUNGFRAUCTB)){
//thr=getThresholdEnergy();
n = controlSocket->ReceiveDataOnly( &thr,sizeof(thr));
thisDetector->currentThresholdEV=thr;
@ -3542,10 +3595,26 @@ int slsDetector::updateDetectorNoWait() {
thisDetector->timerValue[PROBES_NUMBER]=retval;
}
//retval=setTrains(tns);
n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
thisDetector->timerValue[CYCLES_NUMBER]=retval;
//retval=setProbes(tns);
if (thisDetector->myDetectorType == JUNGFRAUCTB){
n = controlSocket->ReceiveDataOnly( &retval,sizeof(int64_t));
if (retval>=0)
thisDetector->timerValue[SAMPLES_JCTB]=retval;
n = controlSocket->ReceiveDataOnly( &ro,sizeof(ro));
thisDetector->roFlags=ro;
//retval=setProbes(tns);
getTotalNumberOfChannels();
// thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
}
return OK;
}
@ -3729,15 +3798,16 @@ int* slsDetector::getDataFromDetector(int *retval){
// int* retval=new int[nel];
if (retval==NULL)
if (retval==NULL) {
retval=new int[nel];
// cout << "*****"<<endl;
} //else cout <<"----"<< retval <<endl;
int ret=FAIL;
char mess[MAX_STR_LENGTH]="Nothing";
#ifdef VERBOSE
//#ifdef VERBOSE
std::cout<< "getting data "<< thisDetector->dataBytes << " " << nel<< std::endl;
#endif
//#endif
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
#ifdef VERBOSE
cout << "ret=" << ret << endl;
@ -3762,9 +3832,9 @@ int* slsDetector::getDataFromDetector(int *retval){
} else {
n=controlSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
#ifdef VERBOSE
//#ifdef VERBOSE
std::cout<< "Received "<< n << " data bytes" << std::endl;
#endif
//#endif
if (n!=thisDetector->dataBytes) {
std::cout<< "wrong data size received from detector: received " << n << " but expected " << thisDetector->dataBytes << std::endl;
thisDetector->stoppedFlag=1;
@ -3775,7 +3845,7 @@ int* slsDetector::getDataFromDetector(int *retval){
return NULL;
}
}
// cout << "get data returning " << endl;
// cout << "get data returning " << endl;
return retval;
};
@ -3800,22 +3870,22 @@ int* slsDetector::readAll(){
while ((retval=getDataFromDetector())){
i++;
//#ifdef VERBOSE
#ifdef VERBOSE
std::cout<< i << std::endl;
//#else
//std::cout << "-" << flush ;
//#endif
#endif
dataQueue.push(retval);
std::cout<< "pushed" << std::endl;
// std::cout<< "pushed" << std::endl;
}
disconnectControl();
}
}
#ifdef VERBOSE
#ifdef VERBOSE
std::cout<< "received "<< i<< " frames" << std::endl;
//#else
// std::cout << std::endl;
#endif
#endif
return dataQueue.front(); // check what we return!
};
@ -3849,24 +3919,26 @@ int slsDetector::readAllNoWait(){
int* slsDetector::startAndReadAll(){
//cout << "Start and read all "<< endl;
int* retval;
#ifdef VERBOSE
//#ifdef VERBOSE
int i=0;
#endif
//#endif
startAndReadAllNoWait();
//#ifdef VERBOSE
// std::cout<< "started" << std::endl;
//#endif
while ((retval=getDataFromDetector())){
#ifdef VERBOSE
#ifdef VERBOSE
i++;
std::cout<< i << std::endl;
//#else
//std::cout<< "-" << flush;
#endif
#endif
dataQueue.push(retval);
//std::cout<< "pushed" << std::endl;
}
disconnectControl();
@ -3990,6 +4062,10 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
(thisDetector->myDetectorType==JUNGFRAU)||
(thisDetector->myDetectorType==MOENCH))
thisDetector->timerValue[PROBES_NUMBER]=0;
if(thisDetector->myDetectorType==JUNGFRAUCTB && index==SAMPLES_JCTB) {
getTotalNumberOfChannels();
// thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
}
}
} else {
if (t>=0)
@ -4003,7 +4079,11 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
setDynamicRange();
//cout << "Changing probes: data size = " << thisDetector->dataBytes <<endl;
}
if ((thisDetector->myDetectorType==JUNGFRAUCTB) && (index==SAMPLES_JCTB)) {
setDynamicRange();
cout << "Changing samples: data size = " << thisDetector->dataBytes <<endl;
}
/* set progress */
if ((index==FRAME_NUMBER) || (index==CYCLES_NUMBER)) {
setTotalProgress();
@ -4535,7 +4615,7 @@ int slsDetector::setDynamicRange(int n){
thisDetector->dynamicRange=n;
retval=thisDetector->dynamicRange;
}
//cout << "detector returned dynamic range " << retval << endl;
if (ret!=FAIL && retval>0) {
/* checking the number of probes to chose the data size */
@ -4544,9 +4624,12 @@ int slsDetector::setDynamicRange(int n){
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChips*thisDetector->nChans*retval/8;
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
thisDetector->nChip[X]=retval/16;
thisDetector->nChips=thisDetector->nChip[X]*thisDetector->nChip[Y];
thisDetector->dataBytes=thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*retval/8;
// thisDetector->nChip[X]=retval/16;
// thisDetector->nChips=thisDetector->nChip[X]*thisDetector->nChip[Y];
// cout << thisDetector->nMod[X]*thisDetector->nMod[Y] << " " << thisDetector->nChans*thisDetector->nChips << " " << retval<< " ";
getTotalNumberOfChannels();
//thisDetector->dataBytes=getTotalNumberOfChannels()*retval/8*thisDetector->timerValue[SAMPLES_JCTB];
//cout << "data bytes: "<< thisDetector->dataBytes << endl;
}
if(thisDetector->myDetectorType==MYTHEN){
if (thisDetector->timerValue[PROBES_NUMBER]!=0)
@ -4598,29 +4681,40 @@ int slsDetector::setROI(int n,ROI roiLimits[]){
int ret = FAIL;
//sort ascending order
int temp;
for(int i=0;i<n;i++){
// cout << "*** ROI "<< i << " xmin " << roiLimits[i].xmin << " xmax "<< roiLimits[i].xmax << endl;
for(int j=i+1;j<n;j++){
if(roiLimits[j].xmin<roiLimits[i].xmin){
temp=roiLimits[i].xmin;roiLimits[i].xmin=roiLimits[j].xmin;roiLimits[j].xmin=temp;
temp=roiLimits[i].xmax;roiLimits[i].xmax=roiLimits[j].xmax;roiLimits[j].xmax=temp;
temp=roiLimits[i].ymin;roiLimits[i].ymin=roiLimits[j].ymin;roiLimits[j].ymin=temp;
temp=roiLimits[i].ymax;roiLimits[i].ymax=roiLimits[j].ymax;roiLimits[j].ymax=temp;
temp=roiLimits[i].xmin;roiLimits[i].xmin=roiLimits[j].xmin;roiLimits[j].xmin=temp;
temp=roiLimits[i].xmax;roiLimits[i].xmax=roiLimits[j].xmax;roiLimits[j].xmax=temp;
temp=roiLimits[i].ymin;roiLimits[i].ymin=roiLimits[j].ymin;roiLimits[j].ymin=temp;
temp=roiLimits[i].ymax;roiLimits[i].ymax=roiLimits[j].ymax;roiLimits[j].ymax=temp;
}
}
// cout << "UUU ROI "<< i << " xmin " << roiLimits[i].xmin << " xmax "<< roiLimits[i].xmax << endl;
}
ret = sendROI(n,roiLimits);
if(ret==FAIL)
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
return ret;
}
slsDetectorDefs::ROI* slsDetector::getROI(int &n){
sendROI();
n=thisDetector->nROI;
return thisDetector->roiLimits;
sendROI(-1,NULL);
n=thisDetector->nROI;
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
return thisDetector->roiLimits;
}
@ -4632,7 +4726,8 @@ int slsDetector::sendROI(int n,ROI roiLimits[]){
int retvalsize=0;
ROI retval[MAX_ROIS];
int nrec=-1;
if (roiLimits==NULL)
roiLimits=thisDetector->roiLimits;
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (connectControl() == OK){
@ -4674,10 +4769,10 @@ int slsDetector::sendROI(int n,ROI roiLimits[]){
thisDetector->nROI = retvalsize;
}
#ifdef VERBOSE
//#ifdef VERBOSE
for(int j=0;j<thisDetector->nROI;j++)
cout<<roiLimits[j].xmin<<"\t"<<roiLimits[j].xmax<<"\t"<<roiLimits[j].ymin<<"\t"<<roiLimits[j].ymax<<endl;
#endif
cout<<"get"<< roiLimits[j].xmin<<"\t"<<roiLimits[j].xmax<<"\t"<<roiLimits[j].ymin<<"\t"<<roiLimits[j].ymax<<endl;
//#endif
return ret;
}
@ -4720,6 +4815,11 @@ int slsDetector::setReadOutFlags(readOutFlags flag){
} else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
thisDetector->roFlags=retval;
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
getTotalNumberOfChannels();
//thisDetector->dataBytes=getTotalNumberOfChannels()*thisDetector->dynamicRange/8*thisDetector->timerValue[SAMPLES_JCTB];
}
}
disconnectControl();
if (ret==FORCE_UPDATE)
@ -4794,15 +4894,22 @@ int slsDetector::executeTrimming(trimMode mode, int par1, int par2, int imod){
};
double* slsDetector::decodeData(int *datain, double *fdata) {
double* slsDetector::decodeData(int *datain, int &nn, double *fdata) {
double *dataout;
if (fdata) {
dataout=fdata;
// printf("not allocating fdata!\n");
}
else {
dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
else {
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
dataout=new double[thisDetector->dataBytes/2];
nn=thisDetector->dataBytes/2;
} else {
dataout=new double[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
nn=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;
}
// printf("allocating fdata!\n");
}
const int bytesize=8;
@ -4817,20 +4924,21 @@ double* slsDetector::decodeData(int *datain, double *fdata) {
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
for (ichan=0; ichan<nch; ichan++) {
// dataout[ichan]=0;
ival=0;
// for (ibyte=0; ibyte<2; ibyte++) {
ibyte=0;
iptr=ptr[ichan*2+ibyte];
ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
ibyte=1;
iptr=ptr[ichan*2+ibyte];
ival|=((iptr<<(ibyte*bytesize))&(0x3f<<(ibyte*bytesize)));
// cout << "nch " << nch << endl;
for (ichan=0; ichan<thisDetector->dataBytes/2; ichan++) {
// // dataout[ichan]=0;
// ival=0;
// // for (ibyte=0; ibyte<2; ibyte++) {
// ibyte=0;
// iptr=ptr[ichan*2+ibyte];
// ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
// ibyte=1;
// iptr=ptr[ichan*2+ibyte];
// ival|=((iptr<<(ibyte*bytesize))&(0x3f<<(ibyte*bytesize)));
// }
dataout[ichan]=ival;
// // }
dataout[ichan]=*((u_int16_t*)ptr);
ptr+=2;
}
} else {
switch (nbits) {
@ -4980,7 +5088,7 @@ int slsDetector::fillModuleMask(int *mM){
int slsDetector::setFlatFieldCorrection(double *corr, double *ecorr) {
if (corr!=NULL) {
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nChans*thisDetector->nChips; ichan++) {
for (int ichan=0; ichan<thisDetector->nMod[Y]*thisDetector->nMod[X]*thisDetector->nChans*thisDetector->nChips; ichan++) {
// #ifdef VERBOSE
// std::cout<< ichan << " "<< corr[ichan] << std::endl;
// #endif
@ -5944,7 +6052,7 @@ int slsDetector:: writeAngularConversion(ofstream &ofs) {
int slsDetector::loadImageToDetector(imageType index,string const fname){
int ret=FAIL;
short int arg[thisDetector->nChans*thisDetector->nChips];
short int arg[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
#ifdef VERBOSE
std::cout<< std::endl<< "Loading ";
@ -6025,7 +6133,7 @@ int slsDetector::getCounterBlock(short int arg[],int startACQ){
int slsDetector::writeCounterBlockFile(string const fname,int startACQ){
int ret=FAIL;
short int counterVals[thisDetector->nChans*thisDetector->nChips];
short int counterVals[thisDetector->nChans*thisDetector->nChips*thisDetector->nMods];
#ifdef VERBOSE
std::cout<< std::endl<< "Reading Counter to \""<<fname;
@ -6947,11 +7055,13 @@ int slsDetector::startReceiver(){
std::cout << "Starting Receiver " << std::endl;
#endif
if (connectData() == OK)
ret=thisReceiver->executeFunction(fnum,mess);
disconnectData();
if(ret==FORCE_UPDATE)
ret=updateReceiver();
else if (ret == FAIL){
ret=thisReceiver->executeFunction(fnum,mess);
disconnectData();
if(ret==FORCE_UPDATE) {
ret=updateReceiver();
// cout<< "FU"<<endl;
} else if (ret == FAIL){
// cout << mess <<endl;
if(strstr(mess,"UDP")!=NULL)
setErrorMask((getErrorMask())|(COULDNOT_CREATE_UDP_SOCKET));
else if(strstr(mess,"file")!=NULL)
@ -6961,7 +7071,7 @@ int slsDetector::startReceiver(){
}
}
//let detector prepare anyway even if receiver didnt work
if((thisDetector->myDetectorType != JUNGFRAU))
if((thisDetector->myDetectorType !=JUNGFRAU))
ret=detectorSendToReceiver(true);
return ret;

View File

@ -632,13 +632,24 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
int getMaxMods(){return thisDetector->nModsMax;}; //
int getTotalNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;};
/** number of rois defined */
int nROI;
/** list of rois */
ROI roiLimits[MAX_ROIS];
/** readout flags */
readOutFlags roFlags;
int getTotalNumberOfChannels(dimension d){return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nMod[d];};
int getMaxNumberOfChannels(){return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;};
int getTotalNumberOfChannels();
//{return thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;};
int getMaxNumberOfChannels(dimension d){return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nModMax[d];};
int getTotalNumberOfChannels(dimension d);
//{return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nMod[d];};
int getMaxNumberOfChannels();//{return thisDetector->nChans*thisDetector->nChips*thisDetector->nModsMax;};
int getMaxNumberOfChannels(dimension d);//{return thisDetector->nChan[d]*thisDetector->nChip[d]*thisDetector->nModMax[d];};
/** Returns number of rois */
int getNRoi(){return thisDetector->nROI;};
@ -1253,7 +1264,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
\param datain data from the detector
\returns pointer to a double array with a data per channel
*/
double* decodeData(int *datain, double *fdata=NULL);
double* decodeData(int *datain, int &nn, double *fdata=NULL);

View File

@ -251,7 +251,7 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
virtual int setTotalProgress()=0;
virtual double* decodeData(int *datain, double *fdata=NULL)=0;
virtual double* decodeData(int *datain, int &nn, double *fdata=NULL)=0;
virtual string getCurrentFileName()=0;

View File

@ -839,6 +839,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
i++;
descrToFuncMap[i].m_pFuncName="samples"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
i++;
/* read only timers */
descrToFuncMap[i].m_pFuncName="exptimel"; //
@ -3992,6 +3996,8 @@ string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {
index=PROBES_NUMBER;
else if (cmd=="measurements")
index=MEASUREMENTS_NUMBER;
else if (cmd=="samples")
index=SAMPLES_JCTB;
else
return string("could not decode timer ")+cmd;
@ -4044,6 +4050,7 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
os << "frames t \t sets the number of frames per cycle (e.g. after each trigger)" << std::endl;
os << "cycles t \t sets the number of cycles (e.g. number of triggers)" << std::endl;
os << "probes t \t sets the number of probes to accumulate (max 3! cycles should be set to 1, frames to the number of pump-probe events)" << std::endl;
os << "samples t \t sets the number of samples expected from the jctb" << std::endl;
os << std::endl;
@ -4057,6 +4064,8 @@ string slsDetectorCommand::helpTimer(int narg, char *args[], int action) {
os << "frames \t gets the number of frames per cycle (e.g. after each trigger)" << std::endl;
os << "cycles \t gets the number of cycles (e.g. number of triggers)" << std::endl;
os << "probes \t gets the number of probes to accumulate" << std::endl;
os << "samples t \t gets the number of samples expected from the jctb" << std::endl;
os << std::endl;
}
@ -4285,6 +4294,10 @@ char answer[1000]="";
flag=NONPARALLEL;
else if (sval=="safe")
flag=SAFE;
else if (sval=="digital")
flag=DIGITAL_ONLY;
else if (sval=="analog_digital")
flag=ANALOG_AND_DIGITAL;
else
return string("could not scan flag ")+string(args[1]);
}
@ -4294,6 +4307,8 @@ char answer[1000]="";
retval = myDet->setReadOutFlags(flag);
// cout << hex << flag << " " << retval << endl;
if(retval == NORMAL_READOUT)
return string("none");
@ -4308,7 +4323,11 @@ char answer[1000]="";
if(retval & NONPARALLEL)
strcat(answer,"nonparallel ");
if(retval & SAFE)
strcat(answer,"safe ");
strcat(answer,"safe ");
if (retval & DIGITAL_ONLY)
strcat(answer,"digital " );
if (retval & ANALOG_AND_DIGITAL)
strcat(answer,"analog_digital ");
if(strlen(answer))
return string(answer);
@ -4343,13 +4362,13 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) {
if (action==PUT_ACTION || action==HELP_ACTION) {
os << "extsig:i mode \t sets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown" << std::endl;
}
if (action==GET_ACTION || action==HELP_ACTION) {
os << "extsig:i \t gets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl;
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, unknown" << std::endl;
os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, unknown" << std::endl;
}
return os.str();
@ -5056,6 +5075,10 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
os << hex << myDet->readRegister(67) << dec;
} else if (cmd=="adcdisable") {
int nroi=0;
ROI roiLimits[MAX_ROIS];
if (action==PUT_ACTION) {
if (sscanf(args[1],"%x",&addr))
@ -5063,19 +5086,69 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
else
return string("Could not scan adcdisable reg ")+string(args[1]);
myDet->writeRegister(94,addr);
/******USE ROI?!?!?!?*********/
// roiLimits[i].xmin;roiLimits[i].xmax;roiLimits[i].ymin;roiLimits[i].ymin;roiLimits[i].ymax
//int mask=1;
int ii=0;
while (ii<32) {
nroi++;
roiLimits[nroi-1].xmin=ii;
roiLimits[nroi-1].ymin=0;
roiLimits[nroi-1].ymax=0;
while ((addr&(1<<ii))) {
ii++;
if (ii>=32)
break;
}
if (ii>=32) {
break;
cout << "ROI "<< nroi << " xmin "<<roiLimits[nroi-1].xmin << " xmax "<< roiLimits[nroi-1].xmax << endl;
roiLimits[nroi-1].xmax=31;
break;
}
roiLimits[nroi-1].xmin=ii;
while ((addr&(1<<ii))==0) {
ii++;
if (ii>=32)
break;
}
roiLimits[nroi-1].xmax=ii-1;
if (ii>=32) {
cout << "ROI "<< nroi << " xmin "<<roiLimits[nroi-1].xmin << " xmax "<< roiLimits[nroi-1].xmax << endl;
nroi++;
break;
}
cout << "ROI "<< nroi << " xmin "<<roiLimits[nroi-1].xmin << " xmax "<< roiLimits[nroi-1].xmax << endl;
}
cout << "********ROI "<< nroi << endl;
myDet->setROI(nroi-1,roiLimits);
// myDet->writeRegister(94,addr);
// myDet->writeRegister(120,addr);
}
ROI *aa=myDet->getROI(nroi);
int reg=0xffffffff;
if (nroi<1)
reg=0;
else {
for (int iroi=0; iroi<nroi; iroi++) {
cout << iroi << " xmin "<< (aa+iroi)->xmin<< " xmax "<< (aa+iroi)->xmax<< endl;
for (int ich=(aa+iroi)->xmin; ich<=(aa+iroi)->xmax; ich++) {
reg&=~(1<<ich);
}
}
}
os << hex << reg << dec;
os << hex << myDet->readRegister(94) << dec;
//os <<" "<< hex << myDet->readRegister(120) << dec;
}
else return helpPattern(narg, args, action);
else return helpPattern(narg, args, action);

View File

@ -301,14 +301,14 @@ int slsDetectorUtils::acquire(int delflag){
}
pthread_mutex_unlock(&mg);
}
#ifdef VERBOSE
#ifdef VERBOSE
cout << "Acquiring " << endl;
#endif
#endif
startAndReadAll();
#ifdef VERBOSE
#ifdef VERBOSE
cout << "finished " << endl;
cout << "returned! " << endl;
#endif
#endif