mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
Merge branch 'developer' into hdf5
This commit is contained in:
@ -23,7 +23,9 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
|
||||
int sz;
|
||||
|
||||
//shmId=-1;
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "init shm"<< endl;
|
||||
#endif
|
||||
switch(type) {
|
||||
case MYTHEN:
|
||||
nch=128; // complete mythen system
|
||||
@ -80,7 +82,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
|
||||
@ -123,7 +125,9 @@ int slsDetector::initSharedMemory(detectorType type, int id) {
|
||||
std::cout<<"*** shmat error (server) ***" << std::endl;
|
||||
return shm_id;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout <<"shm done"<<endl;
|
||||
#endif
|
||||
|
||||
/**
|
||||
shm_id returns -1 is shared memory initialization fails
|
||||
@ -243,6 +247,7 @@ slsDetector::slsDetector(int pos, detectorType type, int id, multiSlsDetector *p
|
||||
|
||||
/**Initializes the detector stucture \sa initializeDetectorSize
|
||||
*/
|
||||
cout << "init det size"<< endl;
|
||||
initializeDetectorSize(type);
|
||||
|
||||
|
||||
@ -636,12 +641,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;
|
||||
@ -686,12 +691,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)
|
||||
@ -793,6 +800,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];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1030,7 +1046,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
|
||||
@ -1673,8 +1689,57 @@ 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];
|
||||
} else
|
||||
cout << "det type is "<< thisDetector->myDetectorType << endl;
|
||||
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){
|
||||
@ -1751,14 +1816,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 ((thisDetector->myDetectorType==MYTHEN) && (dr==24))
|
||||
dr=32;
|
||||
@ -1771,8 +1828,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];
|
||||
|
||||
}
|
||||
|
||||
@ -3742,6 +3799,7 @@ int slsDetector::getChanRegs(double* retval,bool fromDetector){
|
||||
|
||||
int slsDetector::updateDetectorNoWait() {
|
||||
|
||||
enum readOutFlags ro;
|
||||
// int ret=OK;
|
||||
enum detectorSettings t;
|
||||
int thr, n, nm;
|
||||
@ -3789,7 +3847,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;
|
||||
@ -3823,10 +3881,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;
|
||||
|
||||
}
|
||||
@ -4013,6 +4087,7 @@ int* slsDetector::getDataFromDetector(int *retval){
|
||||
nodatadetectortype = true;
|
||||
}
|
||||
|
||||
|
||||
if (!nodatadetectortype && retval==NULL)
|
||||
retval=new int[nel];
|
||||
|
||||
@ -4057,8 +4132,13 @@ int* slsDetector::getDataFromDetector(int *retval){
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
// for (int ib=0; ib<thisDetector->dataBytes/8; ib++)
|
||||
// cout << ((*(((u_int64_t*)retval)+ib))>>17&1) ;
|
||||
|
||||
|
||||
}
|
||||
// cout << "get data returning " << endl;
|
||||
// cout << "get data returning " << endl;
|
||||
// cout << endl;
|
||||
return retval;
|
||||
|
||||
};
|
||||
@ -4073,8 +4153,8 @@ int* slsDetector::readAll(){
|
||||
int fnum=F_READ_ALL;
|
||||
int* retval; // check what we return!
|
||||
|
||||
int i=0;
|
||||
#ifdef VERBOSE
|
||||
int i=0;
|
||||
std::cout<< "Reading all frames "<< std::endl;
|
||||
#endif
|
||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||
@ -4082,22 +4162,17 @@ int* slsDetector::readAll(){
|
||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
|
||||
while ((retval=getDataFromDetector())){
|
||||
#ifdef VERBOSE
|
||||
i++;
|
||||
//#ifdef VERBOSE
|
||||
std::cout<< i << std::endl;
|
||||
//#else
|
||||
//std::cout << "-" << flush ;
|
||||
//#endif
|
||||
#endif
|
||||
dataQueue.push(retval);
|
||||
std::cout<< "pushed" << std::endl;
|
||||
}
|
||||
disconnectControl();
|
||||
}
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "received "<< i<< " frames" << std::endl;
|
||||
//#else
|
||||
// std::cout << std::endl;
|
||||
#endif
|
||||
return dataQueue.front(); // check what we return!
|
||||
|
||||
@ -4132,12 +4207,14 @@ 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;
|
||||
@ -4150,6 +4227,8 @@ int* slsDetector::startAndReadAll(){
|
||||
//std::cout<< "-" << flush;
|
||||
#endif
|
||||
dataQueue.push(retval);
|
||||
|
||||
//std::cout<< "pushed" << std::endl;
|
||||
}
|
||||
disconnectControl();
|
||||
|
||||
@ -4268,10 +4347,15 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
if (t>=0)
|
||||
thisDetector->timerValue[index]=t;
|
||||
if((thisDetector->myDetectorType==GOTTHARD)||
|
||||
(thisDetector->myDetectorType==PROPIX)||
|
||||
(thisDetector->myDetectorType==JUNGFRAU)||
|
||||
(thisDetector->myDetectorType==MOENCH))
|
||||
thisDetector->timerValue[PROBES_NUMBER]=0;
|
||||
(thisDetector->myDetectorType==PROPIX)||
|
||||
(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)
|
||||
@ -4281,6 +4365,19 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t){
|
||||
std::cout<< "Timer " << index << " set to "<< thisDetector->timerValue[index] << "ns" << std::endl;
|
||||
#endif
|
||||
|
||||
if ((thisDetector->myDetectorType==MYTHEN)&&(index==PROBES_NUMBER)) {
|
||||
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();
|
||||
}
|
||||
|
||||
if(t!=-1){
|
||||
if ((thisDetector->myDetectorType==MYTHEN)&&(index==PROBES_NUMBER)) {
|
||||
@ -4843,7 +4940,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 */
|
||||
|
||||
@ -4852,9 +4949,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)
|
||||
@ -4907,29 +5007,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;
|
||||
}
|
||||
|
||||
|
||||
@ -4941,7 +5052,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){
|
||||
@ -4983,10 +5095,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;
|
||||
}
|
||||
@ -5029,6 +5141,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)
|
||||
@ -5103,49 +5220,52 @@ 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];
|
||||
// printf("allocating fdata!\n");
|
||||
}
|
||||
const int bytesize=8;
|
||||
|
||||
int ival=0;
|
||||
char *ptr=(char*)datain;
|
||||
char iptr;
|
||||
double *dataout;
|
||||
if (fdata) {
|
||||
dataout=fdata;
|
||||
// printf("not allocating fdata!\n");
|
||||
if (thisDetector->myDetectorType==JUNGFRAUCTB) nn=thisDetector->dataBytes/2;
|
||||
} else {
|
||||
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||
nn=thisDetector->dataBytes/2;
|
||||
dataout=new double[nn];
|
||||
|
||||
// std::cout<< "nn is "<< nn << std::endl;
|
||||
} 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;
|
||||
|
||||
int ival=0;
|
||||
char *ptr=(char*)datain;
|
||||
char iptr;
|
||||
|
||||
int nbits=thisDetector->dynamicRange;
|
||||
int nch=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;
|
||||
int ipos=0, ichan=0, ibyte;
|
||||
|
||||
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
|
||||
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
|
||||
|
||||
for (ichan=0; ichan<nn; ichan++) {
|
||||
// // }
|
||||
dataout[ichan]=*((u_int16_t*)ptr);
|
||||
ptr+=2;
|
||||
}
|
||||
|
||||
int nbits=thisDetector->dynamicRange;
|
||||
int nch=thisDetector->nChans*thisDetector->nChips*thisDetector->nMods;
|
||||
int ipos=0, ichan=0, ibyte;
|
||||
|
||||
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)));
|
||||
|
||||
// }
|
||||
dataout[ichan]=ival;
|
||||
}
|
||||
} else {
|
||||
std::cout<< "decoded "<< ichan << " channels" << std::endl;
|
||||
} else {
|
||||
switch (nbits) {
|
||||
case 1:
|
||||
for (ibyte=0; ibyte<thisDetector->dataBytes; ibyte++) {
|
||||
iptr=ptr[ibyte]&0x1;
|
||||
iptr=ptr[ibyte];//&0x1;
|
||||
for (ipos=0; ipos<8; ipos++) {
|
||||
// dataout[ibyte*2+ichan]=((iptr&((0xf)<<ichan))>>ichan)&0xf;
|
||||
ival=(iptr>>(ipos))&0x1;
|
||||
@ -5156,7 +5276,7 @@ double* slsDetector::decodeData(int *datain, double *fdata) {
|
||||
break;
|
||||
case 4:
|
||||
for (ibyte=0; ibyte<thisDetector->dataBytes; ibyte++) {
|
||||
iptr=ptr[ibyte]&0xff;
|
||||
iptr=ptr[ibyte];
|
||||
for (ipos=0; ipos<2; ipos++) {
|
||||
// dataout[ibyte*2+ichan]=((iptr&((0xf)<<ichan))>>ichan)&0xf;
|
||||
ival=(iptr>>(ipos*4))&0xf;
|
||||
@ -5174,36 +5294,32 @@ double* slsDetector::decodeData(int *datain, double *fdata) {
|
||||
case 16:
|
||||
for (ichan=0; ichan<nch; ichan++) {
|
||||
// dataout[ichan]=0;
|
||||
ival=0;
|
||||
for (ibyte=0; ibyte<2; ibyte++) {
|
||||
iptr=ptr[ichan*2+ibyte];
|
||||
ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
|
||||
}
|
||||
dataout[ichan]=ival;
|
||||
// ival=0;
|
||||
// for (ibyte=0; ibyte<2; ibyte++) {
|
||||
// iptr=ptr[ichan*2+ibyte];
|
||||
// ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
|
||||
// }
|
||||
dataout[ichan]=*((u_int16_t*)ptr);
|
||||
ptr+=2;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(thisDetector->myDetectorType == MYTHEN){
|
||||
for (ichan=0; ichan<nch; ichan++) {
|
||||
ival=datain[ichan]&0xffffff;
|
||||
dataout[ichan]=ival;
|
||||
}
|
||||
}
|
||||
for (ichan=0; ichan<nch; ichan++) {
|
||||
dataout[ichan]=datain[ichan];
|
||||
}
|
||||
int mask=0xffffffff;
|
||||
if(thisDetector->myDetectorType == MYTHEN) mask=0xffffff;
|
||||
for (ichan=0; ichan<nch; ichan++) {
|
||||
dataout[ichan]=datain[ichan]&mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (ichan=0; ichan<nch; ichan++) {
|
||||
dataout[ichan]=datain[ichan];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (ichan=0; ichan<nch; ichan++) {
|
||||
dataout[ichan]=datain[ichan];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "decoded "<< ichan << " channels" << std::endl;
|
||||
#endif
|
||||
//#ifdef VERBOSE
|
||||
//#endif
|
||||
|
||||
return dataout;
|
||||
}
|
||||
@ -5293,7 +5409,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
|
||||
@ -6271,7 +6387,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 ";
|
||||
@ -6352,7 +6468,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;
|
||||
@ -6924,7 +7040,7 @@ int slsDetector::powerChip(int ival){
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
int retval=-1;
|
||||
|
||||
if(thisDetector->myDetectorType != JUNGFRAU){
|
||||
if(thisDetector->myDetectorType != JUNGFRAU && thisDetector->myDetectorType != JUNGFRAUCTB ){
|
||||
std::cout << "Not implemented for this detector" << std::endl;
|
||||
return FAIL;
|
||||
}
|
||||
@ -7571,6 +7687,7 @@ int slsDetector::startReceiver(){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Starting Receiver " << std::endl;
|
||||
#endif
|
||||
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->executeFunction(fnum,mess);
|
||||
disconnectData();
|
||||
@ -7587,7 +7704,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;
|
||||
@ -7774,7 +7891,54 @@ int slsDetector::resetFramesCaught(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
// int* slsDetector::readFrameFromReceiver(char* fName, int &acquisitionIndex, int &frameIndex, int &subFrameIndex){
|
||||
// int fnum=F_READ_RECEIVER_FRAME;
|
||||
// int nel=thisDetector->dataBytes/sizeof(int);
|
||||
// int* retval=new int[nel];
|
||||
// int ret=FAIL;
|
||||
// int n;
|
||||
// char mess[MAX_STR_LENGTH]="Nothing";
|
||||
// if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
|
||||
// #ifdef VERBOSE
|
||||
// std::cout<< "slsDetector: Reading frame from receiver "<< thisDetector->dataBytes << " " <<nel <<std::endl;
|
||||
// #endif
|
||||
// if (connectData() == OK){
|
||||
// dataSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||
// dataSocket->ReceiveDataOnly(&ret,sizeof(ret));
|
||||
// if (ret==FAIL) {
|
||||
// n= dataSocket->ReceiveDataOnly(mess,sizeof(mess));
|
||||
// std::cout<< "Detector returned: " << mess << " " << n << std::endl;
|
||||
// delete [] retval;
|
||||
// disconnectData();
|
||||
// return NULL;
|
||||
// } else {
|
||||
// n=dataSocket->ReceiveDataOnly(fName,MAX_STR_LENGTH);
|
||||
// n=dataSocket->ReceiveDataOnly(&acquisitionIndex,sizeof(acquisitionIndex));
|
||||
// n=dataSocket->ReceiveDataOnly(&frameIndex,sizeof(frameIndex));
|
||||
// if(thisDetector->myDetectorType == EIGER)
|
||||
// n=dataSocket->ReceiveDataOnly(&subFrameIndex,sizeof(subFrameIndex));
|
||||
// n=dataSocket->ReceiveDataOnly(retval,thisDetector->dataBytes);
|
||||
// #ifdef VERBOSE
|
||||
// std::cout<< "Received "<< n << " data bytes" << std::endl;
|
||||
// #endif
|
||||
// if (n!=thisDetector->dataBytes) {
|
||||
// std::cout<<endl<< "wrong data size received: received " << n << " but expected from receiver " << thisDetector->dataBytes << std::endl;
|
||||
// ret=FAIL;
|
||||
// delete [] retval;
|
||||
// disconnectData();
|
||||
// return NULL; }
|
||||
// //jungfrau masking adcval
|
||||
// if(thisDetector->myDetectorType == JUNGFRAU){
|
||||
// for(unsigned int i=0;i<nel;i++){
|
||||
// retval[i] = (retval[i] & 0x3FFF3FFF);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// disconnectData();
|
||||
// }
|
||||
// }
|
||||
// return retval;
|
||||
// };
|
||||
|
||||
|
||||
|
||||
|
@ -655,13 +655,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 the enable if data will be flipped across x or y axis
|
||||
* \param d axis across which data is flipped
|
||||
@ -1297,7 +1308,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);
|
||||
|
||||
|
||||
|
||||
@ -1625,6 +1636,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
||||
*/
|
||||
int resetFramesCaught();
|
||||
|
||||
|
||||
/** Locks/Unlocks the connection to the receiver
|
||||
/param lock sets (1), usets (0), gets (-1) the lock
|
||||
/returns lock status of the receiver
|
||||
|
@ -146,6 +146,7 @@ int slsDetectorActions::getActionMode(int iaction){
|
||||
int slsDetectorActions::setScan(int iscan, string script, int nvalues, double *values, string par, int precision) {
|
||||
if (iscan>=0 && iscan<MAX_SCAN_LEVELS) {
|
||||
|
||||
// cout << "settings script to " << script <<endl;
|
||||
if (script=="") {
|
||||
scanMode[iscan]=noScan;
|
||||
} else {
|
||||
@ -160,6 +161,8 @@ int slsDetectorActions::setScan(int iscan, string script, int nvalues, double *v
|
||||
scanMode[iscan]=trimbitsScan;
|
||||
} else if (script=="position") {
|
||||
scanMode[iscan]=positionScan;
|
||||
} else if (script=="dac") {
|
||||
scanMode[iscan]=dacScan;
|
||||
} else {
|
||||
scanMode[iscan]=scriptScan;
|
||||
}
|
||||
@ -202,15 +205,6 @@ int slsDetectorActions::setScan(int iscan, string script, int nvalues, double *v
|
||||
|
||||
setTotalProgress();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return scanMode[iscan];
|
||||
} else
|
||||
return -1;
|
||||
@ -233,6 +227,8 @@ int slsDetectorActions::setScanScript(int iscan, string script) {
|
||||
scanMode[iscan]=trimbitsScan;
|
||||
} else if (script=="position") {
|
||||
scanMode[iscan]=positionScan;
|
||||
} else if (script=="dac") {
|
||||
scanMode[iscan]=dacScan;
|
||||
} else {
|
||||
scanMode[iscan]=scriptScan;
|
||||
}
|
||||
@ -425,6 +421,9 @@ int slsDetectorActions::executeScan(int level, int istep) {
|
||||
case thresholdScan:
|
||||
setDAC((dacs_t)currentScanVariable[level],THRESHOLD,0); // threshold scan
|
||||
break;
|
||||
case dacScan:
|
||||
setDAC((dacs_t)currentScanVariable[level],(slsDetectorDefs::dacIndex)atoi(getScanParameter(level).c_str()),0);
|
||||
break;
|
||||
case trimbitsScan:
|
||||
trimbit=(int)currentScanVariable[level];
|
||||
if(getDetectorsType() == EIGER)
|
||||
|
@ -25,7 +25,7 @@ class slsDetectorActions : public virtual slsDetectorBase
|
||||
{
|
||||
public :
|
||||
|
||||
enum {noScan, energyScan, thresholdScan, trimbitsScan, positionScan, scriptScan };
|
||||
enum {noScan, energyScan, thresholdScan, trimbitsScan, positionScan, scriptScan, dacScan };
|
||||
|
||||
|
||||
/** default constructor */
|
||||
|
@ -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;
|
||||
@ -504,8 +504,8 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
||||
|
||||
/** Reads frames from receiver through a constant socket
|
||||
*/
|
||||
virtual void readFrameFromReceiver()=0;
|
||||
|
||||
// virtual int* readFrameFromReceiver(char* fName, int &acquisitionIndex, int &frameIndex, int &subFrameIndex)=0;
|
||||
virtual void readFrameFromReceiver()=0;
|
||||
|
||||
/** Sets the read receiver frequency
|
||||
if data required from receiver randomly readRxrFrequency=0,
|
||||
|
@ -791,6 +791,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="v_limit"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDAC;
|
||||
i++;
|
||||
|
||||
/* r/w timers */
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="temp_adc"; //
|
||||
@ -878,6 +882,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"; //
|
||||
@ -964,6 +972,20 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
i++;
|
||||
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="dbitclk"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="dbitphase"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed;
|
||||
i++;
|
||||
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="dbitpipeline"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdSpeed;
|
||||
i++;
|
||||
|
||||
|
||||
|
||||
/* settings dump/retrieve */
|
||||
descrToFuncMap[i].m_pFuncName="config";
|
||||
@ -1126,6 +1148,11 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
|
||||
i++;
|
||||
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="dut_clk"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdPattern;
|
||||
i++;
|
||||
|
||||
|
||||
/* pulse */
|
||||
|
||||
@ -3830,6 +3857,8 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) {
|
||||
dac=V_POWER_IO;
|
||||
else if (cmd== "v_chip")
|
||||
dac=V_POWER_CHIP;
|
||||
else if (cmd== "v_limit")
|
||||
dac=V_LIMIT;
|
||||
else
|
||||
return string("cannot decode dac ")+cmd;
|
||||
|
||||
@ -3863,7 +3892,7 @@ string slsDetectorCommand::cmdDAC(int narg, char *args[], int action) {
|
||||
sprintf(answer,"%f",myDet->setDAC(-1,dac,mode));
|
||||
#endif
|
||||
if(mode)
|
||||
strcat(answer,"mV");
|
||||
strcat(answer," mV");
|
||||
return string(answer);
|
||||
|
||||
}
|
||||
@ -4021,7 +4050,7 @@ string slsDetectorCommand::cmdADC(int narg, char *args[], int action) {
|
||||
return string("cannot set ")+cmd;
|
||||
|
||||
if (sscanf(args[0],"adc:%d",&idac)==1) {
|
||||
printf("chiptestboard!\n");
|
||||
// printf("chiptestboard!\n");
|
||||
adc=(dacIndex)(idac+1000);
|
||||
} else if (cmd=="temp_adc")
|
||||
adc=TEMPERATURE_ADC;
|
||||
@ -4147,6 +4176,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;
|
||||
|
||||
@ -4200,6 +4231,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;
|
||||
|
||||
|
||||
@ -4213,6 +4245,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;
|
||||
|
||||
}
|
||||
@ -4348,9 +4382,16 @@ string slsDetectorCommand::cmdSpeed(int narg, char *args[], int action) {
|
||||
index=ADC_CLOCK;
|
||||
else if (cmd=="adcphase") {
|
||||
index=ADC_PHASE;
|
||||
t=100000;
|
||||
t=100000;
|
||||
} else if (cmd=="adcpipeline")
|
||||
index=ADC_PIPELINE;
|
||||
else if (cmd=="dbitclk")
|
||||
index=DBIT_CLOCK;
|
||||
else if (cmd=="dbitphase") {
|
||||
index=DBIT_PHASE;
|
||||
t=100000;
|
||||
} else if (cmd=="dbitpipeline")
|
||||
index=DBIT_PIPELINE;
|
||||
else
|
||||
return string("could not decode speed variable ")+cmd;
|
||||
|
||||
@ -4425,50 +4466,59 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
||||
|
||||
readOutFlags flag=GET_READOUT_FLAGS;
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
string sval=string(args[1]);
|
||||
if (sval=="none")
|
||||
flag=NORMAL_READOUT;
|
||||
else if (sval=="storeinram")
|
||||
flag=STORE_IN_RAM;
|
||||
else if (sval=="tot")
|
||||
flag=TOT_MODE;
|
||||
else if (sval=="continous")
|
||||
flag=CONTINOUS_RO;
|
||||
else if (sval=="parallel")
|
||||
flag=PARALLEL;
|
||||
else if (sval=="nonparallel")
|
||||
flag=NONPARALLEL;
|
||||
else if (sval=="safe")
|
||||
flag=SAFE;
|
||||
else
|
||||
return string("could not scan flag ")+string(args[1]);
|
||||
}
|
||||
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
string sval=string(args[1]);
|
||||
if (sval=="none")
|
||||
flag=NORMAL_READOUT;
|
||||
else if (sval=="storeinram")
|
||||
flag=STORE_IN_RAM;
|
||||
else if (sval=="tot")
|
||||
flag=TOT_MODE;
|
||||
else if (sval=="continous")
|
||||
flag=CONTINOUS_RO;
|
||||
else if (sval=="parallel")
|
||||
flag=PARALLEL;
|
||||
else if (sval=="nonparallel")
|
||||
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]);
|
||||
}
|
||||
|
||||
myDet->setOnline(ONLINE_FLAG);
|
||||
retval = myDet->setReadOutFlags(flag);
|
||||
|
||||
retval = myDet->setReadOutFlags(flag);
|
||||
// cout << hex << flag << " " << retval << endl;
|
||||
|
||||
if(retval == NORMAL_READOUT)
|
||||
return string("none");
|
||||
if(retval == NORMAL_READOUT)
|
||||
return string("none");
|
||||
|
||||
if(retval & STORE_IN_RAM)
|
||||
strcat(answer,"storeinram ");
|
||||
if(retval & TOT_MODE)
|
||||
strcat(answer,"tot ");
|
||||
if(retval & CONTINOUS_RO)
|
||||
strcat(answer,"continous ");
|
||||
if(retval & PARALLEL)
|
||||
strcat(answer,"parallel ");
|
||||
if(retval & NONPARALLEL)
|
||||
strcat(answer,"nonparallel ");
|
||||
if(retval & SAFE)
|
||||
strcat(answer,"safe ");
|
||||
if(strlen(answer))
|
||||
return string(answer);
|
||||
if(retval & STORE_IN_RAM)
|
||||
strcat(answer,"storeinram ");
|
||||
if(retval & TOT_MODE)
|
||||
strcat(answer,"tot ");
|
||||
if(retval & CONTINOUS_RO)
|
||||
strcat(answer,"continous ");
|
||||
if(retval & PARALLEL)
|
||||
strcat(answer,"parallel ");
|
||||
if(retval & NONPARALLEL)
|
||||
strcat(answer,"nonparallel ");
|
||||
if(retval & 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);
|
||||
|
||||
return string("unknown");
|
||||
return string("unknown");
|
||||
|
||||
} else if (cmd=="extsig") {
|
||||
externalSignalFlag flag=GET_EXTERNAL_SIGNAL_FLAG;
|
||||
@ -4487,10 +4537,8 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
|
||||
|
||||
return myDet->externalSignalType(myDet->setExternalSignalFlags(flag,is));
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if (cmd=="programfpga") {
|
||||
} else if (cmd=="programfpga") {
|
||||
if (action==GET_ACTION)
|
||||
return string("cannot get");
|
||||
if(strstr(args[1],".pof")==NULL)
|
||||
@ -4543,14 +4591,15 @@ 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;
|
||||
|
||||
os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl;
|
||||
os << "resetfpga f \t resets fpga, f can be any value" << 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();
|
||||
@ -5261,7 +5310,26 @@ string slsDetectorCommand::cmdPattern(int narg, char *args[], int action) {
|
||||
|
||||
os << hex << myDet->readRegister(67) << dec;
|
||||
|
||||
} else if (cmd=="dut_clk") {
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%x",&addr))
|
||||
;
|
||||
else
|
||||
return string("Could not scan dut_clk reg ")+string(args[1]);
|
||||
|
||||
|
||||
myDet->writeRegister(123,addr); //0x7b
|
||||
}
|
||||
|
||||
|
||||
|
||||
os << hex << myDet->readRegister(123) << dec; //0x7b
|
||||
} else if (cmd=="adcdisable") {
|
||||
|
||||
int nroi=0;
|
||||
ROI roiLimits[MAX_ROIS];
|
||||
|
||||
if (action==PUT_ACTION) {
|
||||
|
||||
if (sscanf(args[1],"%x",&addr))
|
||||
@ -5269,19 +5337,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);
|
||||
|
||||
|
||||
|
||||
|
@ -151,7 +151,7 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
}
|
||||
|
||||
if(receiver){
|
||||
pthread_mutex_lock(&mg);
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
if(getReceiverStatus()!=IDLE)
|
||||
stopReceiver();
|
||||
//multi detectors shouldnt have different receiver read frequencies enabled/disabled
|
||||
@ -161,7 +161,7 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
}
|
||||
if(setReceiverOnline()==OFFLINE_FLAG)
|
||||
*stoppedFlag=1;
|
||||
pthread_mutex_unlock(&mg);
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -173,9 +173,9 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
//resets frames caught in receiver
|
||||
if(receiver){
|
||||
pthread_mutex_lock(&mg);
|
||||
resetFramesCaught();
|
||||
pthread_mutex_unlock(&mg);
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
resetFramesCaught();
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -269,7 +269,7 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
aclog->addStep(getCurrentPosition(), getCurrentFileName());
|
||||
|
||||
if (eclog)
|
||||
eclog->addStep(setDAC(-1,THRESHOLD,0), getCurrentFileName());
|
||||
eclog->addStep(setDAC(-1,THRESHOLD,0), getCurrentFileName());
|
||||
|
||||
|
||||
if (*correctionMask&(1<< I0_NORMALIZATION)) {
|
||||
@ -280,7 +280,7 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
setCurrentFrameIndex(0);
|
||||
|
||||
if(receiver)
|
||||
pthread_mutex_lock(&mg);
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
if (multiframe>1)
|
||||
setFrameIndex(0);
|
||||
else
|
||||
@ -288,30 +288,33 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
|
||||
|
||||
if(receiver){
|
||||
pthread_mutex_unlock(&mg);
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
pthread_mutex_lock(&mp);
|
||||
createFileName();
|
||||
pthread_mutex_unlock(&mp);
|
||||
//send receiver file name
|
||||
pthread_mutex_lock(&mg);
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
setFileName(fileIO::getFileName());
|
||||
|
||||
//start receiver
|
||||
if(startReceiver() == FAIL) {
|
||||
cout << "Start receiver failed " << endl;
|
||||
stopReceiver();
|
||||
*stoppedFlag=1;
|
||||
pthread_mutex_unlock(&mg);
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
break;
|
||||
}
|
||||
pthread_mutex_unlock(&mg);
|
||||
cout << "Receiver started " << endl;
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
cout << "Acquiring " << endl;
|
||||
#endif
|
||||
#endif
|
||||
startAndReadAll();
|
||||
#ifdef VERBOSE
|
||||
cout << "finished " << endl;
|
||||
cout << "detector finished " << endl;
|
||||
#ifdef VERBOSE
|
||||
cout << "returned! " << endl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -341,17 +344,20 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
} else
|
||||
break;
|
||||
|
||||
|
||||
pthread_mutex_lock(&mg);
|
||||
while (dataQueueSize()) usleep(100000);
|
||||
// cout << "mglock " << endl;;
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
// cout << "done " << endl;;
|
||||
//offline
|
||||
if(setReceiverOnline()==OFFLINE_FLAG){
|
||||
if ((getDetectorsType()==GOTTHARD) || (getDetectorsType()==MOENCH) || (getDetectorsType()==JUNGFRAU) ){
|
||||
if ((getDetectorsType()==GOTTHARD) || (getDetectorsType()==MOENCH) || (getDetectorsType()==JUNGFRAU)|| (getDetectorsType()==JUNGFRAUCTB) ){
|
||||
if((*correctionMask)&(1<<WRITE_FILE))
|
||||
closeDataFile();
|
||||
}
|
||||
}
|
||||
//online
|
||||
else{
|
||||
|
||||
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
|
||||
stopAcquisition();
|
||||
stopReceiver();
|
||||
@ -359,9 +365,9 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
break;
|
||||
}
|
||||
stopReceiver();
|
||||
// cout<<"***********receiver stopped"<<endl;
|
||||
// cout<<"***********receiver stopped"<<endl;
|
||||
}
|
||||
pthread_mutex_unlock(&mg);
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
|
||||
|
||||
|
||||
@ -439,9 +445,9 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
#endif
|
||||
if(*correctionMask&(1<<WRITE_FILE))
|
||||
IncrementFileIndex();
|
||||
pthread_mutex_lock(&mg);
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
pthread_mutex_unlock(&mg);
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -452,14 +458,14 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
#endif
|
||||
if(*correctionMask&(1<<WRITE_FILE))
|
||||
IncrementFileIndex();
|
||||
pthread_mutex_lock(&mg);
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
setFileIndex(fileIO::getFileIndex());
|
||||
pthread_mutex_unlock(&mg);
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
|
||||
if (measurement_finished){
|
||||
pthread_mutex_lock(&mg);
|
||||
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
|
||||
measurement_finished(im,*fileIndex,measFinished_p);
|
||||
pthread_mutex_unlock(&mg);
|
||||
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
|
||||
}
|
||||
|
||||
if (*stoppedFlag) {
|
||||
|
@ -690,6 +690,7 @@ virtual int createReceivingDataSockets(const bool destroy = false){return -1;};
|
||||
|
||||
/** Reads frames from receiver through a constant socket
|
||||
*/
|
||||
|
||||
virtual void readFrameFromReceiver(){};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user