Merge branch '3.0.1' into developer

This commit is contained in:
Dhanya Maliakal 2017-09-19 17:19:36 +02:00
commit 092487c08e
14 changed files with 1500 additions and 980 deletions

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware
URL: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_detector_software.git
Repsitory UUID: 5d45181f177b552819bd60947c6cf4f0abae7681
Revision: 1543
Repsitory UUID: 3c1eb747d1930d6d38030a5a607f72d3b58a7a21
Revision: 1544
Branch: 3.0
Last Changed Author: Dhanya_Maliakal
Last Changed Rev: 1548
Last Changed Date: 2017-08-28 12:02:38.000000002 +0200 ./multiSlsDetector/multiSlsDetector.cpp
Last Changed Rev: 1549
Last Changed Date: 2017-09-14 17:05:04.000000002 +0200 ./threadFiles/ThreadPool.o

File diff suppressed because it is too large Load Diff

View File

@ -204,6 +204,9 @@ class multiSlsDetector : public slsDetectorUtils {
/** external gui */
bool externalgui;
/** receiver online flag - is set if the receiver is connected, unset if socket connection is not possible */
int receiverOnlineFlag;
} sharedMultiSlsDetector;
@ -1233,6 +1236,11 @@ class multiSlsDetector : public slsDetectorUtils {
*/
int getFramesCaughtByReceiver();
/** gets the number of frames caught by any one receiver (to avoid using threadpool)
\returns number of frames caught by any one receiver (master receiver if exists)
*/
int getFramesCaughtByAnyReceiver();
/** gets the current frame index of receiver
\returns current frame index of receiver
*/

View File

@ -1,11 +1,11 @@
//#define SVNPATH ""
#define SVNURLLIB "git@git.psi.ch:sls_detectors_software/sls_detector_software.git"
//#define SVNREPPATH ""
#define SVNREPUUIDLIB "5d45181f177b552819bd60947c6cf4f0abae7681"
//#define SVNREV 0x1548
#define SVNREPUUIDLIB "3c1eb747d1930d6d38030a5a607f72d3b58a7a21"
//#define SVNREV 0x1549
//#define SVNKIND ""
//#define SVNSCHED ""
#define SVNAUTHLIB "Dhanya_Maliakal"
#define SVNREVLIB 0x1548
#define SVNDATELIB 0x20170828
#define SVNREVLIB 0x1549
#define SVNDATELIB 0x20170914
//

View File

@ -190,9 +190,9 @@ slsDetector::slsDetector(int pos, int id, multiSlsDetector *p) :slsDetectorUtils
if it fails the detector id is incremented until it succeeds
*/
shmId=initSharedMemory(type,id);
id++;
++id;
}
id--;
--id;
#ifdef VERBOSE
std::cout<< "Detector id is " << id << std::endl;
#endif
@ -238,9 +238,9 @@ slsDetector::slsDetector(int pos, detectorType type, int id, multiSlsDetector *p
if it fails the detector id is incremented until it succeeds
*/
shmId=initSharedMemory(type,id);
id++;
++id;
}
id--;
--id;
#ifdef VERBOSE
std::cout<< "Detector id is " << id << " type is " << type << std::endl;
#endif
@ -304,9 +304,9 @@ slsDetector::slsDetector(int pos, char *name, int id, int cport,multiSlsDetector
if it fails the detector id is incremented until it succeeds
*/
shmId=initSharedMemory(type,id);
id++;
++id;
}
id--;
--id;
#ifdef VERBOSE
std::cout<< "Detector id is " << id << std::endl;
#endif
@ -782,13 +782,13 @@ int slsDetector::initializeDetectorSize(detectorType type) {
thisDetector->flippedData[1] = 0;
thisDetector->zmqport = 0;
for (int ia=0; ia<MAX_ACTIONS; ia++) {
for (int ia=0; ia<MAX_ACTIONS; ++ia) {
strcpy(thisDetector->actionScript[ia],"none");
strcpy(thisDetector->actionParameter[ia],"none");
}
for (int iscan=0; iscan<MAX_SCAN_LEVELS; iscan++) {
for (int iscan=0; iscan<MAX_SCAN_LEVELS; ++iscan) {
thisDetector->scanMode[iscan]=0;
strcpy(thisDetector->scanScript[iscan],"none");
@ -833,7 +833,7 @@ int slsDetector::initializeDetectorSize(detectorType type) {
fferrors=(double*)(goff+thisDetector->fferroff);
detectorModules=(sls_detector_module*)(goff+ thisDetector->modoff);
#ifdef VERBOSE
// for (int imod=0; imod< thisDetector->nModsMax; imod++)
// for (int imod=0; imod< thisDetector->nModsMax; ++imod)
// std::cout<< hex << detectorModules+imod << dec <<std::endl;
#endif
@ -948,7 +948,7 @@ int slsDetector::initializeDetectorStructure() {
//p2=(char*)thisDetector;
/** for each of the detector modules up to the maximum number which can be installed initlialize the sls_detector_module structure \sa ::sls_detector_module*/
for (int imod=0; imod<thisDetector->nModsMax; imod++) {
for (int imod=0; imod<thisDetector->nModsMax; ++imod) {
@ -967,37 +967,37 @@ int slsDetector::initializeDetectorStructure() {
thisMod->reg=0;
/** initializes the dacs values to 0 */
for (int idac=0; idac<thisDetector->nDacs; idac++) {
for (int idac=0; idac<thisDetector->nDacs; ++idac) {
*(dacs+idac+thisDetector->nDacs*imod)=0;
}
/** initializes the adc values to 0 */
for (int iadc=0; iadc<thisDetector->nAdcs; iadc++) {
for (int iadc=0; iadc<thisDetector->nAdcs; ++iadc) {
*(adcs+iadc+thisDetector->nAdcs*imod)=0;
}
/** initializes the chip registers to 0 */
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
for (int ichip=0; ichip<thisDetector->nChips; ++ichip) {
*(chipregs+ichip+thisDetector->nChips*imod)=-1;
}
/** initializes the channel registers to 0 */
for (int ichan=0; ichan<thisDetector->nChans*thisDetector->nChips; ichan++) {
for (int ichan=0; ichan<thisDetector->nChans*thisDetector->nChips; ++ichan) {
*(chanregs+ichan+thisDetector->nChips*thisDetector->nChans*imod)=-1;
}
/** initializes the gain values to 0 */
for (int igain=0; igain<thisDetector->nGain; igain++) {
for (int igain=0; igain<thisDetector->nGain; ++igain) {
*(gain+igain+thisDetector->nGain*imod)=0;
}
/** initializes the offset values to 0 */
for (int ioffset=0; ioffset<thisDetector->nOffset; ioffset++) {
for (int ioffset=0; ioffset<thisDetector->nOffset; ++ioffset) {
*(offset+ioffset+thisDetector->nOffset*imod)=0;
}
@ -1733,7 +1733,7 @@ int slsDetector::getTotalNumberOfChannels() {
if (thisDetector->nChan[X]>=32) {
if (thisDetector->nROI>0) {
thisDetector->nChan[X]-=32;
for (int iroi=0; iroi<thisDetector->nROI; iroi++)
for (int iroi=0; iroi<thisDetector->nROI; ++iroi)
thisDetector->nChan[X]+=thisDetector->roiLimits[iroi].xmax-thisDetector->roiLimits[iroi].xmin+1;
}
}
@ -2493,7 +2493,7 @@ dacs_t slsDetector::setDAC(dacs_t val, dacIndex index, int mV, int imod){
*(dacs+index+imod*thisDetector->nDacs)=retval[0];
}
else {
for (imod=0; imod<thisDetector->nModsMax; imod++)
for (imod=0; imod<thisDetector->nModsMax; ++imod)
*(dacs+index+imod*thisDetector->nDacs)=retval[0];
}
}
@ -2605,9 +2605,9 @@ int slsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod){
chamax=thisDetector->nChans;
}*/
// for (int im=mmin; im<mmax; im++) {
// for (int ichi=chimin; ichi<chimax; ichi++) {
// for (int icha=chamin; icha<chamax; icha++) {
// for (int im=mmin; im<mmax; ++im) {
// for (int ichi=chimin; ichi<chimax; ++ichi) {
// for (int icha=chamin; icha<chamax; ++icha) {
myChan.chan=ichan;//icha;
myChan.chip=ichip;//ichi;
myChan.module=imod;//im;
@ -2675,9 +2675,9 @@ int slsDetector::setChannel(sls_detector_channel chan){
for (int im=mmin; im<mmax; im++) {
for (int ichi=chimin; ichi<chimax; ichi++) {
for (int icha=chamin; icha<chamax; icha++) {
for (int im=mmin; im<mmax; ++im) {
for (int ichi=chimin; ichi<chimax; ++ichi) {
for (int icha=chamin; icha<chamax; ++icha) {
*(chanregs+im*thisDetector->nChans*thisDetector->nChips+ichi*thisDetector->nChips+icha)=retval;
@ -2783,14 +2783,14 @@ int slsDetector::setChip(int reg, int ichip, int imod){
myChip.nchan=thisDetector->nChans;
myChip.reg=reg;
for (int im=mmin; im<mmax; im++) {
for (int ichi=chimin; ichi<chimax; ichi++) {
for (int im=mmin; im<mmax; ++im) {
for (int ichi=chimin; ichi<chimax; ++ichi) {
myChip.chip=ichi;
myChip.module=im;
if (chanregs)
myChip.chanregs=(chanregs+ichi*thisDetector->nChans+im*thisDetector->nChans*thisDetector->nChips);
else {
for (int i=0; i<thisDetector->nChans; i++)
for (int i=0; i<thisDetector->nChans; ++i)
chregs[i]=-1;
myChip.chanregs=chregs;
}
@ -2889,7 +2889,7 @@ slsDetectorDefs::sls_detector_chip slsDetector::getChip(int ichip, int imod){
if (chipregs)
*(chipregs+ichip+imod*thisDetector->nChips)=myChip.reg;
if (chanregs) {
for (int ichan=0; ichan<thisDetector->nChans; ichan++)
for (int ichan=0; ichan<thisDetector->nChans; ++ichan)
*(chanregs+imod*thisDetector->nChans*thisDetector->nChips+ichip*thisDetector->nChans+ichan)=*((myChip.chanregs)+ichan);
}
}
@ -2927,7 +2927,7 @@ int slsDetector::setModule(int reg, int imod){
for (int im=mmin; im<mmax; im++) {
for (int im=mmin; im<mmax; ++im) {
myModule.module=im;
myModule.nchan=thisDetector->nChans;
@ -2947,34 +2947,34 @@ int slsDetector::setModule(int reg, int imod){
}
for (int i=0; i<thisDetector->nAdcs; i++)
for (int i=0; i<thisDetector->nAdcs; ++i)
ads[i]=-1;
if (chanregs)
myModule.chanregs=chanregs+im*thisDetector->nChips*thisDetector->nChans;
else {
for (int i=0; i<thisDetector->nChans*thisDetector->nChips; i++)
for (int i=0; i<thisDetector->nChans*thisDetector->nChips; ++i)
charegs[i]=-1;
myModule.chanregs=charegs;
}
if (chipregs)
myModule.chipregs=chanregs+im*thisDetector->nChips;
else {
for (int ichip=0; ichip<thisDetector->nChips; ichip++)
for (int ichip=0; ichip<thisDetector->nChips; ++ichip)
chiregs[ichip]=-1;
myModule.chipregs=chiregs;
}
if (dacs)
myModule.dacs=dacs+im*thisDetector->nDacs;
else {
for (int i=0; i<thisDetector->nDacs; i++)
for (int i=0; i<thisDetector->nDacs; ++i)
das[i]=-1;
myModule.dacs=das;
}
if (adcs)
myModule.adcs=adcs+im*thisDetector->nAdcs;
else {
for (int i=0; i<thisDetector->nAdcs; i++)
for (int i=0; i<thisDetector->nAdcs; ++i)
ads[i]=-1;
myModule.adcs=ads;
}
@ -3055,25 +3055,25 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
if(thisDetector->myDetectorType != JUNGFRAU){
if(tb) {
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
for (int ichip=0; ichip<thisDetector->nChips; ++ichip) {
if (chipregs)
chipregs[ichip+thisDetector->nChips*imod]=module.chipregs[ichip];
if (chanregs) {
for (int i=0; i<thisDetector->nChans; i++) {
for (int i=0; i<thisDetector->nChans; ++i) {
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=module.chanregs[ichip*thisDetector->nChans+i];
}
}
}
}
if (adcs) {
for (int i=0; i<thisDetector->nAdcs; i++)
for (int i=0; i<thisDetector->nAdcs; ++i)
adcs[i+imod*thisDetector->nAdcs]=module.adcs[i];
}
}
if (dacs) {
for (int i=0; i<thisDetector->nDacs; i++)
for (int i=0; i<thisDetector->nDacs; ++i)
dacs[i+imod*thisDetector->nDacs]=module.dacs[i];
}
@ -3085,12 +3085,12 @@ int slsDetector::setModule(sls_detector_module module, int iodelay, int tau, int
}
if ((thisDetector->nGain) && (gainval) && (gain)) {
for (int i=0; i<thisDetector->nGain; i++)
for (int i=0; i<thisDetector->nGain; ++i)
gain[i+imod*thisDetector->nGain]=gainval[i];
}
if ((thisDetector->nOffset) && (offsetval) && (offset)) {
for (int i=0; i<thisDetector->nOffset; i++)
for (int i=0; i<thisDetector->nOffset; ++i)
offset[i+imod*thisDetector->nOffset]=offsetval[i];
}
@ -3185,25 +3185,25 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod){
thisDetector->nAdcs=myMod->nadc;
if(thisDetector->myDetectorType != JUNGFRAU){
for (int ichip=0; ichip<thisDetector->nChips; ichip++) {
for (int ichip=0; ichip<thisDetector->nChips; ++ichip) {
if (chipregs)
chipregs[ichip+thisDetector->nChips*imod]=myMod->chipregs[ichip];
if (chanregs) {
for (int i=0; i<thisDetector->nChans; i++) {
for (int i=0; i<thisDetector->nChans; ++i) {
chanregs[i+ichip*thisDetector->nChans+thisDetector->nChips*thisDetector->nChans*imod]=myMod->chanregs[ichip*thisDetector->nChans+i];
}
}
}
if (adcs) {
for (int i=0; i<thisDetector->nAdcs; i++)
for (int i=0; i<thisDetector->nAdcs; ++i)
adcs[i+imod*thisDetector->nAdcs]=myMod->adcs[i];
}
}
if (dacs) {
for (int i=0; i<thisDetector->nDacs; i++)
for (int i=0; i<thisDetector->nDacs; ++i)
dacs[i+imod*thisDetector->nDacs]=myMod->dacs[i];
}
(detectorModules+imod)->gain=myMod->gain;
@ -3214,12 +3214,12 @@ slsDetectorDefs::sls_detector_module *slsDetector::getModule(int imod){
}
if ((thisDetector->nGain) && (gainval) && (gain)) {
for (int i=0; i<thisDetector->nGain; i++)
for (int i=0; i<thisDetector->nGain; ++i)
gain[i+imod*thisDetector->nGain]=gainval[i];
}
if ((thisDetector->nOffset) && (offsetval) && (offset)) {
for (int i=0; i<thisDetector->nOffset; i++)
for (int i=0; i<thisDetector->nOffset; ++i)
offset[i+imod*thisDetector->nOffset]=offsetval[i];
}
@ -3682,7 +3682,7 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
modma=thisDetector->nMod[X]*thisDetector->nMod[Y];
}
for (im=modmi; im<modma; im++) {
for (im=modmi; im<modma; ++im) {
ostringstream ostfn, oscfn;
myMod->module=im;
@ -3823,12 +3823,12 @@ slsDetectorDefs::detectorSettings slsDetector::setSettings( detectorSettings ise
int slsDetector::getChanRegs(double* retval,bool fromDetector){
int n=getTotalNumberOfChannels();
if(fromDetector){
for(int im=0;im<setNumberOfModules();im++)
for(int im=0;im<setNumberOfModules();++im)
getModule(im);
}
//the original array has 0 initialized
if(chanregs){
for (int i=0; i<n; i++)
for (int i=0; i<n; ++i)
retval[i] = (double) (chanregs[i] & TRIMBITMASK);
}
return n;
@ -4235,7 +4235,7 @@ int* slsDetector::getDataFromDetector(int *retval){
}
return NULL;
}
// for (int ib=0; ib<thisDetector->dataBytes/8; ib++)
// for (int ib=0; ib<thisDetector->dataBytes/8; ++ib)
// cout << ((*(((u_int64_t*)retval)+ib))>>17&1) ;
@ -4266,7 +4266,7 @@ int* slsDetector::readAll(){
while ((retval=getDataFromDetector())){
#ifdef VERBOSE
i++;
++i;
std::cout<< i << std::endl;
#endif
dataQueue.push(retval);
@ -4328,7 +4328,7 @@ int* slsDetector::startAndReadAll(){
//#endif
while ((retval=getDataFromDetector())){
#ifdef VERBOSE
i++;
++i;
std::cout<< i << std::endl;
//#else
//std::cout<< "-" << flush;
@ -4346,7 +4346,7 @@ int* slsDetector::startAndReadAll(){
#endif
return dataQueue.front(); // check what we return!
/* while ((retval=getDataFromDetectorNoWait()))
i++;
++i;
#ifdef VERBOSE
std::cout<< "Received " << i << " frames"<< std::endl;
#endif
@ -5119,10 +5119,10 @@ int slsDetector::setROI(int n,ROI roiLimits[]){
//sort ascending order
int temp;
for(int i=0;i<n;i++){
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++){
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;
@ -5201,13 +5201,13 @@ int slsDetector::sendROI(int n,ROI roiLimits[]){
//update client
if(ret!=FAIL){
for(int i=0;i<retvalsize;i++)
for(int i=0;i<retvalsize;++i)
thisDetector->roiLimits[i]=retval[i];
thisDetector->nROI = retvalsize;
}
//#ifdef VERBOSE
for(int j=0;j<thisDetector->nROI;j++)
for(int j=0;j<thisDetector->nROI;++j)
cout<<"get"<< roiLimits[j].xmin<<"\t"<<roiLimits[j].xmax<<"\t"<<roiLimits[j].ymin<<"\t"<<roiLimits[j].ymax<<endl;
//#endif
@ -5366,7 +5366,7 @@ double* slsDetector::decodeData(int *datain, int &nn, double *fdata) {
if (thisDetector->timerValue[PROBES_NUMBER]==0) {
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
for (ichan=0; ichan<nn; ichan++) {
for (ichan=0; ichan<nn; ++ichan) {
// // }
dataout[ichan]=*((u_int16_t*)ptr);
ptr+=2;
@ -5376,38 +5376,38 @@ double* slsDetector::decodeData(int *datain, int &nn, double *fdata) {
} else {
switch (nbits) {
case 1:
for (ibyte=0; ibyte<thisDetector->dataBytes; ibyte++) {
for (ibyte=0; ibyte<thisDetector->dataBytes; ++ibyte) {
iptr=ptr[ibyte];//&0x1;
for (ipos=0; ipos<8; ipos++) {
for (ipos=0; ipos<8; ++ipos) {
// dataout[ibyte*2+ichan]=((iptr&((0xf)<<ichan))>>ichan)&0xf;
ival=(iptr>>(ipos))&0x1;
dataout[ichan]=ival;
ichan++;
++ichan;
}
}
break;
case 4:
for (ibyte=0; ibyte<thisDetector->dataBytes; ibyte++) {
for (ibyte=0; ibyte<thisDetector->dataBytes; ++ibyte) {
iptr=ptr[ibyte];
for (ipos=0; ipos<2; ipos++) {
for (ipos=0; ipos<2; ++ipos) {
// dataout[ibyte*2+ichan]=((iptr&((0xf)<<ichan))>>ichan)&0xf;
ival=(iptr>>(ipos*4))&0xf;
dataout[ichan]=ival;
ichan++;
++ichan;
}
}
break;
case 8:
for (ichan=0; ichan<thisDetector->dataBytes; ichan++) {
for (ichan=0; ichan<thisDetector->dataBytes; ++ichan) {
ival=ptr[ichan]&0xff;
dataout[ichan]=ival;
}
break;
case 16:
for (ichan=0; ichan<nch; ichan++) {
for (ichan=0; ichan<nch; ++ichan) {
// dataout[ichan]=0;
// ival=0;
// for (ibyte=0; ibyte<2; ibyte++) {
// for (ibyte=0; ibyte<2; ++ibyte) {
// iptr=ptr[ichan*2+ibyte];
// ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
// }
@ -5418,13 +5418,13 @@ double* slsDetector::decodeData(int *datain, int &nn, double *fdata) {
default:
int mask=0xffffffff;
if(thisDetector->myDetectorType == MYTHEN) mask=0xffffff;
for (ichan=0; ichan<nch; ichan++) {
for (ichan=0; ichan<nch; ++ichan) {
dataout[ichan]=datain[ichan]&mask;
}
}
}
} else {
for (ichan=0; ichan<nch; ichan++) {
for (ichan=0; ichan<nch; ++ichan) {
dataout[ichan]=datain[ichan];
}
}
@ -5485,7 +5485,7 @@ int slsDetector::setFlatFieldCorrection(string fname)
int nm=getNMods();
int chpm[nm];
int mMask[nm];
for (int i=0; i<nm; i++) {
for (int i=0; i<nm; ++i) {
chpm[im]=getChansPerMod(im);
mMask[im]=im;
}
@ -5512,7 +5512,7 @@ int slsDetector::setFlatFieldCorrection(string fname)
int slsDetector::fillModuleMask(int *mM){
if (mM)
for (int i=0; i<getNMods(); i++)
for (int i=0; i<getNMods(); ++i)
mM[i]=i;
return getNMods();
@ -5521,7 +5521,7 @@ int slsDetector::fillModuleMask(int *mM){
int slsDetector::setFlatFieldCorrection(double *corr, double *ecorr) {
if (corr!=NULL) {
for (int ichan=0; ichan<thisDetector->nMod[Y]*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
@ -5559,7 +5559,7 @@ int slsDetector::getFlatFieldCorrection(double *corr, double *ecorr) {
std::cout<< "Flat field correction is enabled" << std::endl;
#endif
if (corr) {
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ichan++) {
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ++ichan) {
// corr[ichan]=(ffcoefficients[ichan]*ffcoefficients[ichan])/(fferrors[ichan]*fferrors[ichan]);
corr[ichan]=ffcoefficients[ichan];
if (ecorr) {
@ -5574,7 +5574,7 @@ int slsDetector::getFlatFieldCorrection(double *corr, double *ecorr) {
std::cout<< "Flat field correction is disabled" << std::endl;
#endif
if (corr)
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ichan++) {
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ++ichan) {
corr[ichan]=1;
if (ecorr)
ecorr[ichan]=0;
@ -5591,7 +5591,7 @@ int slsDetector::flatFieldCorrect(double* datain, double *errin, double* dataout
#endif
double e, eo;
if (thisDetector->correctionMask & (1<<FLAT_FIELD_CORRECTION)) {
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nChans*thisDetector->nChips; ichan++) {
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nChans*thisDetector->nChips; ++ichan) {
if (errin==NULL) {
e=0;
} else {
@ -5765,7 +5765,7 @@ int slsDetector::rateCorrect(double* datain, double *errin, double* dataout, dou
#ifdef VERBOSE
std::cout<< "Rate correcting data with dead time "<< tau << " and acquisition time "<< t << std::endl;
#endif
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ichan++) {
for (int ichan=0; ichan<thisDetector->nMod[X]*thisDetector->nMod[Y]*thisDetector->nChans*thisDetector->nChips; ++ichan) {
if (errin==NULL) {
e=sqrt(datain[ichan]);
@ -5824,10 +5824,10 @@ int slsDetector::setBadChannelCorrection(int nch, int *chs, int ff) {
if (nch<MAX_BADCHANS && nch>0) {
thisDetector->correctionMask|=(1<<DISCARD_BAD_CHANNELS);
thisDetector->nBadChans=0;
for (int ich=0 ;ich<nch; ich++) {
for (int ich=0 ;ich<nch; ++ich) {
if (chs[ich]>=0 && chs[ich]<getMaxNumberOfChannels()) {
thisDetector->badChansList[ich]=chs[ich];
thisDetector->nBadChans++;
++thisDetector->nBadChans;
// cout << "det : " << thisDetector->nBadChans << " " << thisDetector->badChansList[ich] << endl;
}
}
@ -5836,7 +5836,7 @@ int slsDetector::setBadChannelCorrection(int nch, int *chs, int ff) {
} else {
if (nch<MAX_BADCHANS && nch>0) {
thisDetector->nBadFF=nch;
for (int ich=0 ;ich<nch; ich++) {
for (int ich=0 ;ich<nch; ++ich) {
thisDetector->badFFList[ich]=chs[ich];
}
}
@ -5863,9 +5863,9 @@ int slsDetector::getBadChannelCorrection(int *bad) {
int ichan;
if (thisDetector->correctionMask&(1<< DISCARD_BAD_CHANNELS)) {
if (bad) {
for (ichan=0; ichan<thisDetector->nBadChans; ichan++)
for (ichan=0; ichan<thisDetector->nBadChans; ++ichan)
bad[ichan]=thisDetector->badChansList[ichan];
for (int ich=0; ich<thisDetector->nBadFF; ich++)
for (int ich=0; ich<thisDetector->nBadFF; ++ich)
bad[ichan+ich]=thisDetector->badFFList[ich];
}
return thisDetector->nBadChans+thisDetector->nBadFF;
@ -6125,7 +6125,8 @@ string slsDetector::setReceiver(string receiverIP){
else
printf("Disabling Data Streaming\n");
// push client state to receiver
parentDet->enableDataStreamingFromReceiver(clientSockets);
/*parentDet->enableDataStreamingFromReceiver(clientSockets);*/
enableDataStreamingFromReceiver(clientSockets);
pthread_mutex_unlock(&ms);
}
}
@ -6445,7 +6446,7 @@ int slsDetector::configureMAC(){
#endif
for(i=0;i<2;i++){
for(i=0;i<2;++i){
if(!strcmp(arg[i],"none")){
std::cout<< "Configure MAC Error. IP/MAC Addresses not set"<< std::endl;
setErrorMask((getErrorMask())|(COULD_NOT_CONFIGURE_MAC));
@ -6590,7 +6591,7 @@ int slsDetector::configureMAC(){
int slsDetector::getAngularConversion(int &direction, angleConversionConstant *angconv) {
direction=thisDetector->angDirection;
if (angconv) {
for (int imod=0; imod<thisDetector->nMods; imod++) {
for (int imod=0; imod<thisDetector->nMods; ++imod) {
(angconv+imod)->center=thisDetector->angOff[imod].center;
(angconv+imod)->r_conversion=thisDetector->angOff[imod].r_conversion;
(angconv+imod)->offset=thisDetector->angOff[imod].offset;
@ -6886,7 +6887,7 @@ int slsDetector::readConfigurationFile(ifstream &infile){
sargname="none";
sargval="0";
getline(infile,str);
iline++;
++iline;
#ifdef VERBOSE
std::cout<< str << std::endl;
#endif
@ -6912,7 +6913,7 @@ int slsDetector::readConfigurationFile(ifstream &infile){
#endif
strcpy(myargs[iargval],sargname.c_str());
args[iargval]=myargs[iargval];
iargval++;
++iargval;
//}
}
ans=cmd->executeLine(iargval,args,PUT_ACTION);
@ -6920,7 +6921,7 @@ int slsDetector::readConfigurationFile(ifstream &infile){
std::cout<< ans << std::endl;
#endif
}
iline++;
++iline;
}
delete cmd;
return OK;
@ -7022,17 +7023,17 @@ int slsDetector::writeConfigurationFile(ofstream &outfile, int id){
char *args[100];
char myargs[100][1000];
for (int ia=0; ia<100; ia++) {
for (int ia=0; ia<100; ++ia) {
//args[ia]=new char[1000];
args[ia]=myargs[ia];
}
for (iv=0; iv<nvar; iv++) {
for (iv=0; iv<nvar; ++iv) {
cout << iv << " " << names[iv] << endl;
if (names[iv]=="extsig") {
for (int is=0; is<nsig; is++) {
for (int is=0; is<nsig; ++is) {
sprintf(args[0],"%s:%d",names[iv].c_str(),is);
if (id>=0)
@ -7109,17 +7110,17 @@ int slsDetector::programFPGA(string fname){
FILE* src = fopen(fname.c_str(),"rb");
FILE* dst = fopen(destfname.c_str(),"wb");
// Remove header (0...11C)
for (filepos=0; filepos < 0x11C; filepos++)
for (filepos=0; filepos < 0x11C; ++filepos)
fgetc(src);
// Write 0x80 times 0xFF (0...7F)
for (filepos=0; filepos < 0x80; filepos++)
for (filepos=0; filepos < 0x80; ++filepos)
fputc(0xFF,dst);
// Swap bits and write to file
for (filepos=0x80; filepos < 0x1000000; filepos++) {
for (filepos=0x80; filepos < 0x1000000; ++filepos) {
x = fgetc(src);
if (x < 0) break;
y=0;
for (i=0; i < 8; i++)
for (i=0; i < 8; ++i)
y=y| ( (( x & (1<<i) ) >> i) << (7-i) ); // This swaps the bits
fputc(y,dst);
}
@ -7199,7 +7200,7 @@ int slsDetector::programFPGA(string fname){
int count = 66;
while(count>0){
usleep(1 * 1000 * 1000);
count--;
--count;
printf("Erasing Flash:%d%%\r",(int) (((double)(65-count)/65)*100));
std::cout << flush;
}
@ -7348,7 +7349,7 @@ int slsDetector::loadSettingsFile(string fname, int imod) {
mmin=imod;
mmax=imod+1;
}
for (int im=mmin; im<mmax; im++) {
for (int im=mmin; im<mmax; ++im) {
ostringstream ostfn;
ostfn << fname;
if(thisDetector->myDetectorType != EIGER){
@ -7388,7 +7389,7 @@ int slsDetector::saveSettingsFile(string fname, int imod) {
mmin=imod;
mmax=imod+1;
}
for (int im=mmin; im<mmax; im++) {
for (int im=mmin; im<mmax; ++im) {
ostringstream ostfn;
if(thisDetector->myDetectorType == EIGER){
ostfn << fname << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
@ -7459,12 +7460,12 @@ int slsDetector::loadCalibrationFile(string fname, int imod) {
int* gainval=0; int* offsetval=0;
if(thisDetector->nGain){
gainval=new int[thisDetector->nGain];
for(int i=0;i<thisDetector->nGain;i++)
for(int i=0;i<thisDetector->nGain;++i)
gainval[i] = -1;
}
if(thisDetector->nOffset){
offsetval=new int[thisDetector->nOffset];
for(int i=0;i<thisDetector->nOffset;i++)
for(int i=0;i<thisDetector->nOffset;++i)
offsetval[i] = -1;
}
@ -7476,7 +7477,7 @@ int slsDetector::loadCalibrationFile(string fname, int imod) {
mmin=imod;
mmax=imod+1;
}
for (int im=mmin; im<mmax; im++) {
for (int im=mmin; im<mmax; ++im) {
ostringstream ostfn;
ostfn << fname ;
if(thisDetector->myDetectorType != EIGER){
@ -7520,7 +7521,7 @@ int slsDetector::saveCalibrationFile(string fname, int imod) {
mmin=imod;
mmax=imod+1;
}
for (int im=mmin; im<mmax; im++) {
for (int im=mmin; im<mmax; ++im) {
ostringstream ostfn;
if(thisDetector->myDetectorType == EIGER)
ostfn << fname << ".sn" << setfill('0') << setw(3) << dec << getId(DETECTOR_SERIAL_NUMBER);
@ -7639,19 +7640,23 @@ slsDetectorDefs::synchronizationMode slsDetector::setSynchronization(synchroniza
/*receiver*/
int slsDetector::setReceiverOnline(int off) {
// int prev = thisDetector->receiverOnlineFlag;
if (off!=GET_ONLINE_FLAG) {
if(strcmp(thisDetector->receiver_hostname,"none")){
thisDetector->receiverOnlineFlag=off;
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG){
setReceiverTCPSocket();
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
std::cout << "cannot connect to receiver" << endl;
setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER));
}
}
}
}
if (off!=GET_ONLINE_FLAG) {
// setting flag to offline
if (off == OFFLINE_FLAG)
thisDetector->receiverOnlineFlag = off;
// set flag to online only if hostname not none
else if(strcmp(thisDetector->receiver_hostname,"none")){
thisDetector->receiverOnlineFlag=off;
}
if (thisDetector->receiverOnlineFlag==ONLINE_FLAG){
setReceiverTCPSocket();
// error in connecting
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
std::cout << "cannot connect to receiver" << endl;
setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER));
}
}
}
return thisDetector->receiverOnlineFlag;
}
@ -7821,17 +7826,14 @@ string slsDetector::setFileName(string s) {
int ret = FAIL;
char arg[MAX_STR_LENGTH]="";
char retval[MAX_STR_LENGTH]="";
string sretval="";
if(!s.empty()){
/*if(!s.empty()){
pthread_mutex_lock(&ms);
fileIO::setFileName(s);
/*if(thisDetector->myDetectorType == EIGER)
parentDet->setDetectorIndex(posId);
else if(parentDet->getNumberOfDetectors()>1)
parentDet->setDetectorIndex(-1);*/
s=parentDet->createReceiverFilePrefix();
pthread_mutex_unlock(&ms);
}
}*/
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
strcpy(arg,s.c_str());
@ -7846,20 +7848,25 @@ string slsDetector::setFileName(string s) {
#ifdef VERBOSE
std::cout << "Complete file prefix from receiver: " << retval << std::endl;
#endif
/*
pthread_mutex_lock(&ms);
fileIO::setFileName(parentDet->getNameFromReceiverFilePrefix(string(retval)));
pthread_mutex_unlock(&ms);
*/
sretval = fileIO::getNameFromReceiverFilePrefix(string(retval));
}
if(ret==FORCE_UPDATE)
updateReceiver();
}
pthread_mutex_lock(&ms);
/*pthread_mutex_lock(&ms);
s = fileIO::getFileName();
pthread_mutex_unlock(&ms);
return s;
return s;*/
return sretval;
}
@ -8169,7 +8176,7 @@ int slsDetector::resetFramesCaught(){
// return NULL; }
// //jungfrau masking adcval
// if(thisDetector->myDetectorType == JUNGFRAU){
// for(unsigned int i=0;i<nel;i++){
// for(unsigned int i=0;i<nel;++i){
// retval[i] = (retval[i] & 0x3FFF3FFF);
// }
// }
@ -8509,7 +8516,7 @@ int64_t slsDetector::clearAllErrorMask(){
clearErrorMask();
pthread_mutex_lock(&ms);
for(int i=0;i<parentDet->getNumberOfDetectors();i++){
for(int i=0;i<parentDet->getNumberOfDetectors();++i){
if(parentDet->getDetectorId(i) == getDetectorId())
parentDet->setErrorMask(parentDet->getErrorMask()|(0<<i));
}
@ -8818,7 +8825,7 @@ int slsDetector::setCTBPattern(string fname) {
while (fread(&word, sizeof(word), 1,fd)) {
setCTBWord(addr,word);
// cout << hex << addr << " " << word << dec << endl;
addr++;
++addr;
}
fclose(fd);

View File

@ -1638,6 +1638,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
int getFramesCaughtByReceiver();
/** gets the number of frames caught by any one receiver (to avoid using threadpool)
\returns number of frames caught by any one receiver (master receiver if exists)
*/
int getFramesCaughtByAnyReceiver() {getFramesCaughtByReceiver();};
/** gets the current frame index of receiver
\returns current frame index of receiver
*/

View File

@ -380,6 +380,54 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
int64_t setNumberOfFrames(int64_t t=-1){return setTimer(FRAME_NUMBER,t);};
int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);};
/** sets/gets the value of important readout speed parameters
\param sp is the parameter to be set/get
\param value is the value to be set, if -1 get value
\returns current value for the specified parameter
\sa speedVariable
*/
virtual int setSpeed(speedVariable sp, int value=-1)=0;
int setClockDivider(int s=-1){return setSpeed(CLOCK_DIVIDER,s);};
/**
set/get readout flags
\param flag readout flag to be set
\returns current flag
*/
virtual int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS)=0;
int getContinuousReadoutFlag(){if(setReadOutFlags()&CONTINOUS_RO) return OK; return FAIL;};
void setContinuousReadoutFlag(){setReadOutFlags(CONTINOUS_RO); };
int getStoreInRamReadoutFlag(){if(setReadOutFlags()&STORE_IN_RAM) return OK; return FAIL;};
void setStoreInRamReadoutFlag(){setReadOutFlags(STORE_IN_RAM); };
int getParallelReadoutFlag(){if(setReadOutFlags()&PARALLEL) return OK; return FAIL;};
void setParallelReadoutFlag(){setReadOutFlags(PARALLEL); };
int getNonParallelReadoutFlag(){if(setReadOutFlags()&NONPARALLEL) return OK; return FAIL;};
void setNonParallelReadoutFlag(){setReadOutFlags(NONPARALLEL); };
int getSafeReadoutFlag(){if(setReadOutFlags()&SAFE) return OK; return FAIL;};
void setSafeReadoutFlag(){setReadOutFlags(SAFE); };
/**
set dacs value
\param val value (in V)
\param index DAC index
\param mV 0 in dac units or 1 in mV
\param imod module number (if -1 alla modules)
\returns current DAC value
*/
virtual dacs_t setDAC(dacs_t val, dacIndex index , int mV, int imod=-1)=0;
int setDACValue(int val, int index , int mV, int imod=-1) { return (int)setDAC((dacs_t)val,(dacIndex)index, mV,imod);};
/**
gets ADC value
\param index ADC index
\param imod module number
\returns current ADC value
*/
virtual dacs_t getADC(dacIndex index, int imod=-1)=0;
int getADCValue(int index, int imod=-1){return (int)getADC((dacIndex)index, imod);};
///////////////////////////////////////////////////////////////////////////////////////////
/**
@short get run status
@ -490,6 +538,11 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
*/
virtual int getFramesCaughtByReceiver()=0;
/** gets the number of frames caught by any one receiver (to avoid using threadpool)
\returns number of frames caught by any one receiver (master receiver if exists)
*/
virtual int getFramesCaughtByAnyReceiver()=0;
/**
\returns current frame index of receiver
*/

File diff suppressed because it is too large Load Diff

View File

@ -316,3 +316,70 @@ string slsDetectorUsers::getCommand(int narg, char *args[], int pos){
int slsDetectorUsers::setClockDivider(int value) {
return myDetector->setClockDivider(value);
}
int slsDetectorUsers::getContinuousReadoutFlag(){
return myDetector->getContinuousReadoutFlag();
}
void slsDetectorUsers::setContinuousReadoutFlag(){
myDetector->setContinuousReadoutFlag();
}
int slsDetectorUsers::getStoreInRamReadoutFlag(){
return myDetector->getStoreInRamReadoutFlag();
}
void slsDetectorUsers::setStoreInRamReadoutFlag(){
myDetector->setStoreInRamReadoutFlag();
}
int slsDetectorUsers::getParallelReadoutFlag(){
return myDetector->getParallelReadoutFlag();
}
void slsDetectorUsers::setParallelReadoutFlag(){
myDetector->setParallelReadoutFlag();
}
int slsDetectorUsers::getNonParallelReadoutFlag(){
return myDetector->getNonParallelReadoutFlag();
}
void slsDetectorUsers::setNonParallelReadoutFlag(){
myDetector->setNonParallelReadoutFlag();
}
int slsDetectorUsers::getSafeReadoutFlag(){
return myDetector->getSafeReadoutFlag();
}
void slsDetectorUsers::setSafeReadoutFlag(){
myDetector->setSafeReadoutFlag();
}
int slsDetectorUsers::setAllTrimbits(int val) {
return myDetector->setAllTrimbits(val);
}
int slsDetectorUsers::setDAC(int id, int dacindex, int val) {
return myDetector->setDACValue(val, dacindex, id);
}
int slsDetectorUsers::getADC(int id, int adcindex) {
return myDetector->getADCValue(adcindex, id);
}

View File

@ -541,6 +541,102 @@ class slsDetectorUsers
*/
string getCommand(int narg, char *args[], int pos=-1);
/************************************************************************
ADVANCED FUNCTIONS
*********************************************************************/
/**
@short sets clock divider of detector
\param value value to be set (-1 gets)
\returns speed of detector
*/
int setClockDivider(int value);
/**
@short gets continuous readout flag
\returns gets continuous readout flag
*/
int getContinuousReadoutFlag();
/**
@short sets continuous readout flag
\returns OK if successful, else false
*/
void setContinuousReadoutFlag();
/**
@short gets store in ram readout flag
\returns gets store in ram readout flag
*/
int getStoreInRamReadoutFlag();
/**
@short sets store in ram readout flag
\returns OK if successful, else false
*/
void setStoreInRamReadoutFlag();
/**
@short gets parallel readout flag
\returns gets parallel readout flag
*/
int getParallelReadoutFlag();
/**
@short sets parallel readout flag
\returns OK if successful, else false
*/
void setParallelReadoutFlag();
/**
@short gets non parallel readout flag
\returns gets non parallel readout flag
*/
int getNonParallelReadoutFlag();
/**
@short sets non parallel readout flag
\returns OK if successful, else false
*/
void setNonParallelReadoutFlag();
/**
@short gets safe readout flag
\returns gets safe readout flag
*/
int getSafeReadoutFlag();
/**
@short sets safe readout flag
\returns OK if successful, else false
*/
void setSafeReadoutFlag();
/**
@short sets all trimbits to value (only available for eiger)
\param val value to be set (-1 gets)
\returns value set
*/
int setAllTrimbits(int val);
/**
@short set dac value
\param id module index (-1 for all)
\param dacindex dac index \sa dacIndex
\param val value to be set (-1 gets)
\returns dac value
*/
int setDAC(int id, int dacindex, int val);
/**
@short get adc value
\param id module index (-1 for all)
\param adcindex adc index \sa dacIndex
\returns adc value
*/
int getADC(int id, int adcindex);
/************************************************************************
STATIC FUNCTIONS
@ -627,6 +723,7 @@ class slsDetectorUsers
if (s== "triggered_gating") return 4; \
return -1; };
private:
multiSlsDetector *myDetector;
multiSlsDetectorCommand *myCmd;

View File

@ -50,8 +50,10 @@ int slsDetectorUtils::acquire(int delflag){
return FAIL;
}
#ifdef VERBOSE
struct timespec begin,end;
clock_gettime(CLOCK_REALTIME, &begin);
#endif
//not in the loop for real time acqusition yet,
//in the real time acquisition loop, processing thread will wait for a post each time
@ -140,9 +142,8 @@ int slsDetectorUtils::acquire(int delflag){
if(receiver){
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
if(getReceiverStatus()!=IDLE)
stopReceiver();
if(setReceiverOnline()==OFFLINE_FLAG)
*stoppedFlag=1;
if(stopReceiver() == FAIL)
*stoppedFlag=1;
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
}
@ -156,12 +157,13 @@ int slsDetectorUtils::acquire(int delflag){
//resets frames caught in receiver
if(receiver){
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
resetFramesCaught();
if (resetFramesCaught() == FAIL)
*stoppedFlag=1;
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
}
for(int im=0;im<nm;im++) {
for(int im=0;im<nm;++im) {
#ifdef VERBOSE
cout << " starting measurement "<< im << " of " << nm << endl;
@ -182,7 +184,7 @@ int slsDetectorUtils::acquire(int delflag){
executeAction(startScript);
}
for (int is0=0; is0<ns0; is0++) {
for (int is0=0; is0<ns0; ++is0) {
// cout << "scan0 loop" << endl;
if (*stoppedFlag==0) {
@ -191,7 +193,7 @@ int slsDetectorUtils::acquire(int delflag){
break;
for (int is1=0; is1<ns1; is1++) {
for (int is1=0; is1<ns1; ++is1) {
// cout << "scan1 loop" << endl;
if (*stoppedFlag==0) {
@ -206,7 +208,7 @@ int slsDetectorUtils::acquire(int delflag){
ResetPositionIndex();
for (int ip=0; ip<np; ip++) {
for (int ip=0; ip<np; ++ip) {
// cout << "positions " << endl;
if (*stoppedFlag==0) {
@ -332,10 +334,13 @@ int slsDetectorUtils::acquire(int delflag){
while (dataQueueSize()) usleep(100000);
// cout << "mglock " << endl;;
pthread_mutex_lock(&mg); //cout << "lock"<< endl;
// cout << "done " << endl;;
//offline
if(setReceiverOnline()==OFFLINE_FLAG){
if(!receiver){
if ((getDetectorsType()==GOTTHARD) || (getDetectorsType()==MOENCH) || (getDetectorsType()==JUNGFRAU)|| (getDetectorsType()==JUNGFRAUCTB) ){
if((*correctionMask)&(1<<WRITE_FILE))
closeDataFile();
@ -343,14 +348,8 @@ int slsDetectorUtils::acquire(int delflag){
}
//online
else{
if(setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG){
stopAcquisition();
stopReceiver();
pthread_mutex_unlock(&mg);
break;
}
stopReceiver();
if (stopReceiver() == FAIL)
*stoppedFlag = 1;
// cout<<"***********receiver stopped"<<endl;
}
pthread_mutex_unlock(&mg);//cout << "unlock"<< endl;
@ -507,8 +506,8 @@ int slsDetectorUtils::acquire(int delflag){
setAcquiringFlag(false);
sem_destroy(&sem_newRTAcquisition);
clock_gettime(CLOCK_REALTIME, &end);
#ifdef VERBOSE
clock_gettime(CLOCK_REALTIME, &end);
cout << "Elapsed time for acquisition:" << (( end.tv_sec - begin.tv_sec ) + ( end.tv_nsec - begin.tv_nsec ) / 1000000000.0) << " seconds" << endl;
#endif
return OK;

View File

@ -669,6 +669,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/
virtual int getFramesCaughtByReceiver()=0;
/** gets the number of frames caught by any one receiver (to avoid using threadpool)
\returns number of frames caught by any one receiver (master receiver if exists)
*/
virtual int getFramesCaughtByAnyReceiver()=0;
/**
\returns current frame index of receiver
*/

View File

@ -545,7 +545,7 @@ void* postProcessing::processData(int delflag) {
//get progress
pthread_mutex_lock(&mg);
if(setReceiverOnline() == ONLINE_FLAG){
caught = getFramesCaughtByReceiver();
caught = getFramesCaughtByAnyReceiver();
}
pthread_mutex_unlock(&mg);

View File

@ -8,189 +8,188 @@
#include <errno.h>
#include <string.h>
#include "Global.h"
#include "sls_detector_defs.h"
#include <iostream>
#include <stdio.h>
using namespace std;
class slsDetector;
template<typename _Ret, typename _Class>
template<typename _Ret>
class func00_t{
public:
func00_t(_Ret (_Class::*fn)(),_Class* ptr):
func00_t(_Ret (slsDetector::*fn)(),slsDetector* ptr):
m_fn(fn),m_ptr(ptr){}
~func00_t() {}
void operator()() const {((m_ptr->*m_fn)());}
private:
_Ret (_Class::*m_fn)();
_Class* m_ptr;
_Ret (slsDetector::*m_fn)();
slsDetector* m_ptr;
};
template<typename _Ret, typename _Class, typename _Store>
template<typename _Ret>
class func0_t{
public:
func0_t(_Ret (_Class::*fn)(),_Class* ptr, _Store* sto):
func0_t(_Ret (slsDetector::*fn)(),slsDetector* ptr, _Ret* sto):
m_fn(fn),m_ptr(ptr),m_store(sto){}
~func0_t() {}
void operator()() const {*m_store = ((m_ptr->*m_fn)());}
private:
_Ret (_Class::*m_fn)();
_Class* m_ptr;
_Store* m_store;
_Ret (slsDetector::*m_fn)();
slsDetector* m_ptr;
_Ret* m_store;
};
template<typename _Ret, typename _Class,typename _Arg1, typename _Store>
template<typename _Ret,typename _Arg1>
class func1_t{
public:
func1_t(_Ret (_Class::*fn)(_Arg1),_Class* ptr,_Arg1 arg1, _Store* sto):
func1_t(_Ret (slsDetector::*fn)(_Arg1),slsDetector* ptr,_Arg1 arg1, _Ret* sto):
m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_store(sto){}
~func1_t() {}
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1));}
private:
_Ret (_Class::*m_fn)(_Arg1);
_Class* m_ptr;
_Ret (slsDetector::*m_fn)(_Arg1);
slsDetector* m_ptr;
_Arg1 m_arg1;
_Store* m_store;
_Ret* m_store;
};
template<typename _Ret, typename _Class,typename _Arg1, typename _Arg2,typename _Store>
template<typename _Ret,typename _Arg1, typename _Arg2>
class func2_t{
public:
func2_t(_Ret (_Class::*fn)(_Arg1,_Arg2),_Class* ptr,_Arg1 arg1,_Arg2 arg2,_Store* sto):
func2_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Ret* sto):
m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_store(sto){}
~func2_t() {}
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2));}
private:
_Ret (_Class::*m_fn)(_Arg1,_Arg2);
_Class* m_ptr;
_Ret (slsDetector::*m_fn)(_Arg1,_Arg2);
slsDetector* m_ptr;
_Arg1 m_arg1;
_Arg2 m_arg2;
_Store* m_store;
_Ret* m_store;
};
template<typename _Ret, typename _Class,typename _Arg1, typename _Arg2, typename _Arg3, typename _Store>
template<typename _Ret,typename _Arg1, typename _Arg2, typename _Arg3>
class func3_t{
public:
func3_t(_Ret (_Class::*fn)(_Arg1,_Arg2,_Arg3),_Class* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Store* sto):
func3_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2,_Arg3),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Ret* sto):
m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_arg3(arg3),m_store(sto){}
~func3_t() {}
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3));}
private:
_Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3);
_Class* m_ptr;
_Ret (slsDetector::*m_fn)(_Arg1,_Arg2,_Arg3);
slsDetector* m_ptr;
_Arg1 m_arg1;
_Arg2 m_arg2;
_Arg3 m_arg3;
_Store* m_store;
_Ret* m_store;
};
template<typename _Ret, typename _Class,typename _Arg1, typename _Arg2, typename _Arg3, typename _Arg4,typename _Store>
template<typename _Ret,typename _Arg1, typename _Arg2, typename _Arg3, typename _Arg4>
class func4_t{
public:
func4_t(_Ret (_Class::*fn)(_Arg1,_Arg2,_Arg3,_Arg4),_Class* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Arg4 arg4,_Store* sto):
func4_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2,_Arg3,_Arg4),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Arg4 arg4,_Ret* sto):
m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_arg3(arg3),m_arg4(arg4),m_store(sto){}
~func4_t() {}
void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3,m_arg4));}
private:
_Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4);
_Class* m_ptr;
_Ret (slsDetector::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4);
slsDetector* m_ptr;
_Arg1 m_arg1;
_Arg2 m_arg2;
_Arg3 m_arg3;
_Arg4 m_arg4;
_Store* m_store;
_Ret* m_store;
};
class Task: public virtual slsDetectorDefs{
class SuperTask: public virtual slsDetectorDefs {
public:
/* Return: int, Param: int */
Task(func1_t <int,slsDetector,int,int>* t): m1(t),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: int, Param: string,int */
Task(func2_t <int,slsDetector,string,int,int>* t): m1(0),m2(t),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: string, Param: string */
Task(func1_t <string,slsDetector,string,string>* t): m1(0),m2(0),m3(t),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: char*, Param: char* */
Task(func1_t <char*,slsDetector,char*,string>* t): m1(0),m2(0),m3(0),m4(t),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: detectorSettings, Param: int */
Task(func1_t <detectorSettings,slsDetector,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(t),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: detectorSettings, Param: detectorSettings,int */
Task(func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(t),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: int, Param: int,int */
Task(func2_t <int,slsDetector,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(t),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: int, Param: int,int,int */
Task(func3_t <int,slsDetector,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(t),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: int, Param: trimMode,int,int,int */
Task(func4_t <int,slsDetector,trimMode,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(t),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: int, Param: none */
Task(func0_t <int,slsDetector,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(t),m11(0),m12(0),m13(0),m14(0),m15(0){};
/* Return: char*, Param: networkParameter,string */
Task(func2_t <string,slsDetector,networkParameter,string,string>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(t),m12(0),m13(0),m14(0),m15(0){};
/* Return: void, Param: none */
Task(func00_t <void,slsDetector>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(t),m13(0),m14(0),m15(0){};
/* Return: int, Param: int,int,detectorSettings,int */
Task(func4_t <int,slsDetector,int,int,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(t),m14(0),m15(0){};
/* Return: dacs_t, Param: dacs_t, dacIndex, int, int */
Task(func4_t <dacs_t,slsDetector,dacs_t,dacIndex,int,int,dacs_t>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(t),m15(0){};
/* Return: dacs_t, Param: dacIndex, int */
Task(func2_t <dacs_t,slsDetector,dacIndex,int,dacs_t>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(t){};
SuperTask():
m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0),m16(0),m17(0),m18(0){};
~SuperTask(){};
protected:
/** Function signature defined
* First argument is Return type, the remaining are arguments
*/
func00_t <void >* m1;
func0_t <int >* m2;
func0_t <double >* m3;
func0_t <runStatus >* m4;
func1_t <int, int>* m5;
func1_t <int, double>* m6;
func1_t <string, string>* m7;
func1_t <detectorSettings, int>* m8;
func2_t <int, int,int>* m9;
func2_t <int, string,int>* m10;
func2_t <dacs_t, dacIndex,int>* m11;
func2_t <detectorSettings, detectorSettings,int>* m12;
func2_t <int64_t, timerIndex,int64_t>* m13;
func2_t <string, networkParameter,string>* m14;
func3_t <int, int,int,int>* m15;
func4_t <int, trimMode,int,int,int>* m16;
func4_t <int, int,int,detectorSettings,int>* m17;
func4_t <dacs_t, dacs_t,dacIndex,int,int>* m18;
};
class Task: public virtual SuperTask {
public:
/** Task Constructors using appropriate function signature
* First argument is Return type, the remaining are arguments
*/
Task(func00_t <void >* t): SuperTask(),fnum(1){m1 = t;};
Task(func0_t <int >* t): SuperTask(),fnum(2){m2 = t;};
Task(func0_t <double >* t): SuperTask(),fnum(3){m3 = t;};
Task(func0_t <runStatus >* t): SuperTask(),fnum(4){m4 = t;};
Task(func1_t <int, int>* t): SuperTask(),fnum(5){m5 = t;};
Task(func1_t <int, double>* t): SuperTask(),fnum(6){m6 = t;};
Task(func1_t <string, string>* t): SuperTask(),fnum(7){m7 = t;};
Task(func1_t <detectorSettings, int>* t): SuperTask(),fnum(8){m8 = t;};
Task(func2_t <int, int,int>* t): SuperTask(),fnum(9){m9 = t;};
Task(func2_t <int, string,int>* t): SuperTask(),fnum(10){m10 = t;};
Task(func2_t <dacs_t, dacIndex,int>* t): SuperTask(),fnum(11){m11 = t;};
Task(func2_t <detectorSettings, detectorSettings,int>* t): SuperTask(),fnum(12){m12 = t;};
Task(func2_t <int64_t, timerIndex,int64_t>* t): SuperTask(),fnum(13){m13 = t;};
Task(func2_t <string, networkParameter,string>* t): SuperTask(),fnum(14){m14 = t;};
Task(func3_t <int, int,int,int>* t): SuperTask(),fnum(15){m15 = t;};
Task(func4_t <int, trimMode,int,int,int>* t): SuperTask(),fnum(16){m16 = t;};
Task(func4_t <int, int,int,detectorSettings,int>* t): SuperTask(),fnum(17){m17 = t;};
Task(func4_t <dacs_t, dacs_t,dacIndex,int,int>* t): SuperTask(),fnum(18){m18 = t;};
~Task(){}
void operator()(){
if(m1) (*m1)();
else if(m2) (*m2)();
else if(m3) (*m3)();
else if(m4) (*m4)();
else if(m5) (*m5)();
else if(m6) (*m6)();
else if(m7) (*m7)();
else if(m8) (*m8)();
else if(m9) (*m9)();
else if(m10) (*m10)();
else if(m11) (*m11)();
else if(m12) (*m12)();
else if(m13) (*m13)();
else if(m14) (*m14)();
else if(m15) (*m15)();
switch(fnum) {
case 1: (*m1)(); break;
case 2: (*m2)(); break;
case 3: (*m3)(); break;
case 4: (*m4)(); break;
case 5: (*m5)(); break;
case 6: (*m6)(); break;
case 7: (*m7)(); break;
case 8: (*m8)(); break;
case 9: (*m9)(); break;
case 10: (*m10)(); break;
case 11: (*m11)(); break;
case 12: (*m12)(); break;
case 13: (*m13)(); break;
case 14: (*m14)(); break;
case 15: (*m15)(); break;
case 16: (*m16)(); break;
case 17: (*m17)(); break;
case 18: (*m18)(); break;
default:
cprintf(RED, "Error: Task not defined. Abort!\n");
break;
}
}
private:
/* Return: int, Param: int */
func1_t <int,slsDetector,int,int>* m1;
/* Return: int, Param: string,int */
func2_t <int,slsDetector,string,int,int>* m2;
/* Return: string, Param: string */
func1_t <string,slsDetector,string,string>* m3;
/* Return: char*, Param: char* */
func1_t <char*,slsDetector,char*,string>* m4;
/* Return: detectorSettings, Param: int */
func1_t <detectorSettings,slsDetector,int,int>* m5;
/* Return: detectorSettings, Param: detectorSettings,int */
func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* m6;
/* Return: int, Param: int,int */
func2_t <int,slsDetector,int,int,int>* m7;
/* Return: int, Param: int,int,int */
func3_t <int,slsDetector,int,int,int,int>* m8;
/* Return: int, Param: trimMode,int,int,int */
func4_t <int,slsDetector,trimMode,int,int,int,int>* m9;
/* Return: int, Param: int */
func0_t <int,slsDetector,int>* m10;
/* Return: char*, Param: networkParameter,string */
func2_t <string,slsDetector,networkParameter,string,string>* m11;
/* Return: void, Param: none */
func00_t <void,slsDetector>* m12;
/* Return: int, Param: int,int,detectorSettings,int */
func4_t <int,slsDetector,int,int,detectorSettings,int,int>* m13;
/* Return: dacs_t, Param: dacs_t, dacIndex, int, int */
func4_t <dacs_t,slsDetector,dacs_t,dacIndex,int,int,dacs_t>* m14;
/* Return: dacs_t, Param: dacIndex, int */
func2_t <dacs_t,slsDetector,dacIndex,int,dacs_t>* m15;
/** function number */
int fnum;
};