diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index 9b6960d36..634bd5671 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -248,11 +248,18 @@ void slsDetectorUtils::acquire(int delflag){ // wait until data processing thread has finished the data +#ifdef VERBOSE + cout << "check data queue size " << endl; +#endif while (dataQueueSize()){ +#ifdef VERBOSE + cout << "AAAAAAAAA check data queue size " << endl; +#endif usleep(100000); } - pthread_mutex_lock(&mp); + + pthread_mutex_lock(&mp); if (*stoppedFlag==0) { executeAction(headerAfter); setLastIndex(*fileIndex); @@ -489,8 +496,10 @@ double slsDetectorUtils::getCurrentProgress() { #ifdef VERBOSE cout << progressIndex << " / " << totalProgress << endl; #endif - return 100.*((double)progressIndex)/((double)totalProgress); + + double p=100.*((double)progressIndex)/((double)totalProgress); pthread_mutex_unlock(&mp); + return p; } diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp index dbd3446c7..92dafb4aa 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp @@ -258,9 +258,9 @@ int angularConversionStatic::finalizeMerging(double *mp, double *mv, double *me, for (int ibin=0; ibin0) { -#ifdef VERBOSE - cout << "finalize " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; -#endif +// #ifdef VERBOSE +// cout << "finalize " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; +// #endif mp[np]=mp[ibin]/mm[ibin]; mv[np]=mv[ibin]/mm[ibin]; me[np]=me[ibin]/mm[ibin]; @@ -323,9 +323,9 @@ int angularConversionStatic::addToMerging(double *p1, double *v1, double *e1, d me[ibin]+=v1[ip]; mm[ibin]++; -#ifdef VERBOSE - cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; -#endif +// #ifdef VERBOSE +// cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; +// #endif } else return slsDetectorDefs::FAIL; } @@ -371,9 +371,9 @@ int angularConversionStatic::addPointToMerging(double p1, double v1, double e1, me[ibin]+=v1; mm[ibin]++; -#ifdef VERBOSE - cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; -#endif +// #ifdef VERBOSE +// cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; +// #endif } else return slsDetectorDefs::FAIL; diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp~ b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp~ index 28b7e93d5..dbd3446c7 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp~ +++ b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.cpp~ @@ -30,7 +30,7 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe angleConversionConstant *p=NULL; int ch0=0; - int chlast=chansPerMod[0]; + int chlast=chansPerMod[0]-1; int nchmod=chansPerMod[0]; p=angOff[imod]; if (mF[imod]==0) @@ -42,7 +42,7 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe #ifdef VERBOSE // cout << "ip " << ip << " ch0 " << ch0 << " chlast " << chlast << " imod " << imod << endl; #endif - if (ip>=chlast) { + if (ip>chlast) { imod++; p=angOff[imod]; if (mF[imod]==0) @@ -50,10 +50,10 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe else enc=pos; - ch0=chlast; + ch0=chlast+1; nchmod=chansPerMod[imod]; if (nchmod>0) - chlast+=nchmod; + chlast=ch0+nchmod-1; } if (p) @@ -69,6 +69,72 @@ double* angularConversionStatic::convertAngles(double pos, int nch, int *chansPe return ang; } +double angularConversionStatic::convertAngle(double pos, int ich, int *chansPerMod, angleConversionConstant **angOff, int *mF, double fo, double go, int angdir) { + + int imod=0; + double ang; + double enc=0, trans=0; + angleConversionConstant *p=NULL; + + int ch0=0; + int chlast=chansPerMod[0]-1; + int nchmod=chansPerMod[0]; + + + + while (ich>chlast) { + imod++; + ch0=chlast+1; + nchmod=chansPerMod[imod]; + chlast=ch0+nchmod-1; + } + + p=angOff[imod]; + + + + switch (mF[imod]) { + case 0: + enc=0; + trans=0; + break; + case 1: + enc=pos; + trans=0; + break; + case -1: + enc=-pos; + trans=0; + break; + case 2: + enc=0; + trans=pos; + break; + case -2: + enc=0; + trans=-pos; + break; + default: + enc=0; + trans=0; + } + + + + if (p) + ang=angle(ich-ch0, \ + enc, \ + fo+go, \ + p->r_conversion, \ + p->center, \ + p->offset, \ + trans, \ + angdir ); + + return ang; + +} + //static! @@ -265,6 +331,53 @@ int angularConversionStatic::addToMerging(double *p1, double *v1, double *e1, d } + return slsDetectorDefs::OK; + +} + +int angularConversionStatic::addPointToMerging(double p1, double v1, double e1, double *mp, double *mv,double *me, int *mm, double binsize,int nbins) { + + + double binmi=-180.; + int ibin=0; + + + if (mp==NULL) //can be changed if we want to use a fixed bin algorithm! + return slsDetectorDefs::FAIL; + + if (mv==NULL) + return slsDetectorDefs::FAIL; + if (me==NULL) + return slsDetectorDefs::FAIL; + if (mm==NULL) + return slsDetectorDefs::FAIL; + + if (binsize<=0) + return slsDetectorDefs::FAIL; + + if (nbins<=0) + return slsDetectorDefs::FAIL; + + + ibin=(int)((p1-binmi)/binsize); + + + if (ibin=0) { + mp[ibin]+=p1; + mv[ibin]+=v1; + if (e1) + me[ibin]+=(e1*e1); + else + me[ibin]+=v1; + mm[ibin]++; + +#ifdef VERBOSE + cout << "add " << ibin << " "<< mm[ibin] << " " << mp[ibin]<< mv[ibin] << me[ibin] << endl; +#endif + } else + return slsDetectorDefs::FAIL; + + return slsDetectorDefs::OK; } diff --git a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp index c44c4e962..b82a5552f 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/postProcessing.cpp @@ -7,7 +7,7 @@ -postProcessing::postProcessing(){ +postProcessing::postProcessing(): expTime(NULL){ pthread_mutex_t mp1 = PTHREAD_MUTEX_INITIALIZER; mp=mp1; pthread_mutex_init(&mp, NULL); @@ -64,6 +64,9 @@ void postProcessing::processFrame(int *myData, int delflag) { fname=createFileName(); + #ifdef VERBOSE + cout << "fname is " << fname << endl; +#endif //Checking for write flag if(*correctionMask&(1<=0) posfinished=v; int retval=posfinished; pthread_mutex_unlock(&mp); return retval;}; - double getCurrentPosition() {double p; pthread_mutex_lock(&mp); p=currentPosition; pthread_mutex_unlock(&mp); return p;} - int setCurrentPosition(double v) { pthread_mutex_lock(&mp); currentPosition=v; pthread_mutex_unlock(&mp); } + double getCurrentPosition() {double p; pthread_mutex_lock(&mp); p=currentPosition; pthread_mutex_unlock(&mp); return p;}; + int setCurrentPosition(double v) { pthread_mutex_lock(&mp); currentPosition=v; pthread_mutex_unlock(&mp); return currentPosition;}; protected: diff --git a/slsDetectorSoftware/usersFunctions/usersFunctions.cpp b/slsDetectorSoftware/usersFunctions/usersFunctions.cpp index 9117592d2..a5e52e4a9 100644 --- a/slsDetectorSoftware/usersFunctions/usersFunctions.cpp +++ b/slsDetectorSoftware/usersFunctions/usersFunctions.cpp @@ -309,12 +309,12 @@ int defaultDataReadyFunc(detectorData* d, void* p) { printf("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU Data received \n"); printf("Filename %s\n",d->fileName); printf("Number of points %d (%d)\n",d->npoints,d->npy); - for(int i=0;inpoints;i++){ + /* for(int i=0;inpoints;i++){ if ((d->angles)) printf("%d-[%f]:%f\n",i,(d->angles)[i],(d->values)[i]); else printf("%d-%f\n",i,(d->values)[i]); - } + }*/ printf("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU Finished \n"); #endif return 0;