From d8d08d5a9b42c0fda0804986c38049e3d9e68de6 Mon Sep 17 00:00:00 2001 From: bergamaschi Date: Fri, 16 Mar 2012 12:25:45 +0000 Subject: [PATCH] solved segmentation fault on may frames, printing progress during acquisition git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@144 951219d9-93cf-4727-9268-0efd64621fa3 --- .../multiSlsDetector/multiSlsDetector.cpp | 14 ++-- .../slsDetector/slsDetector.cpp | 8 +- .../slsDetector/slsDetectorCommand.cpp | 22 ++--- .../slsDetector/slsDetectorUtils.cpp | 83 +++++++++---------- 4 files changed, 60 insertions(+), 67 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index dd019afc5..8c66a2b14 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -1077,8 +1077,8 @@ int* multiSlsDetector::readAll(){ i++; #ifdef VERBOSE std::cout<< i << std::endl; -#else - std::cout << "-" << flush; + //#else + //std::cout << "-" << flush; #endif dataQueue.push(retval); } @@ -1117,8 +1117,8 @@ int* multiSlsDetector::startAndReadAll(){ i++; #ifdef VERBOSE std::cout<< i << std::endl; -#else - std::cout << "-" << flush; + //#else + //std::cout << "-" << flush; #endif dataQueue.push(retval); } @@ -2887,8 +2887,10 @@ int multiSlsDetector::writeConfigurationFile(string const fname){ ofstream outfile; - // int ret; - +#ifdef VERBOSE + int ret; +#endif + outfile.open(fname.c_str(),ios_base::out); if (outfile.is_open()) { diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 9b75368c4..4be4fa5b4 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -3080,8 +3080,8 @@ int* slsDetector::readAll(){ i++; #ifdef VERBOSE std::cout<< i << std::endl; -#else - std::cout << "-" << flush ; + //#else + //std::cout << "-" << flush ; #endif dataQueue.push(retval); } @@ -3141,8 +3141,8 @@ int* slsDetector::startAndReadAll(){ i++; #ifdef VERBOSE std::cout<< i << std::endl; -#else - std::cout<< "-" << flush; + //#else + //std::cout<< "-" << flush; #endif dataQueue.push(retval); } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index cc64305da..065153b5a 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -619,15 +619,15 @@ string slsDetectorCommand::executeLine(int narg, char *args[], int action) { if(key==descrToFuncMap[i].m_pFuncName){ #ifdef VERBOSE - std::cout<setOnline(ONLINE_FLAG); myDet->acquire(1); - return string("ok"); + return string(""); } @@ -770,7 +770,7 @@ string slsDetectorCommand::cmdData(int narg, char *args[], int action) { myDet->readAll(); myDet->processData(1); myDet->setThreadedProcessing(b); - return string("ok"); + return string(""); } } @@ -798,11 +798,11 @@ string slsDetectorCommand::cmdFrame(int narg, char *args[], int action) { } else { b=myDet->setThreadedProcessing(-1); myDet->setThreadedProcessing(0); - myDet->setOnline(ONLINE_FLAG); - myDet->readFrame(); - myDet->processData(1); + myDet->setOnline(ONLINE_FLAG); + myDet->readFrame(); + myDet->processData(1); myDet->setThreadedProcessing(b); - return string("ok"); + return string("ok"); } } @@ -1763,7 +1763,7 @@ string slsDetectorCommand::helpScripts(int narg, char *args[], int action) { string slsDetectorCommand::cmdScans(int narg, char *args[], int action) { int is=-1, ival, ns=0; - char answer[MAX_STR_LENGTH*10]; + char answer[MAX_SCAN_STEPS*10]; float *values; if (action==HELP_ACTION) return helpScans(narg,args,action); diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp index c23406301..0904c051c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp @@ -1661,22 +1661,28 @@ void* slsDetectorUtils::processData(int delflag) { while((queuesize=dataQueue.size())>0) { #ifdef VERBOSE - std::cout<< " queue size " << queuesize << endl; + // std::cout<< " queue size " << queuesize << endl; #endif - pthread_mutex_unlock(&mp); // cout << "thread mutex unlock line 6543" << endl; //queuesize=dataQueue.size(); /** Pop data queue */ myData=dataQueue.front(); // get the data from the queue + pthread_mutex_unlock(&mp); + + if (myData) { progressIndex++; + //#ifdef VERBOSE + cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%"; #ifdef VERBOSE - cout << "Progress is " << getCurrentProgress() << " \%" << endl; + cout << endl; +#else + cout << "\r" << flush; #endif //process data @@ -1714,11 +1720,11 @@ void* slsDetectorUtils::processData(int delflag) { ffcdata=new float[getTotalNumberOfChannels()]; ffcerr=new float[getTotalNumberOfChannels()]; #ifdef VERBOSE - cout << "array size " << getTotalNumberOfChannels() << endl; + // cout << "array size " << getTotalNumberOfChannels() << endl; #endif flatFieldCorrect(rcdata,rcerr,ffcdata,ffcerr); #ifdef VERBOSE - cout << "FF corr done " << endl; + // cout << "FF corr done " << endl; #endif delete [] rcdata; rcdata=NULL; @@ -1733,7 +1739,7 @@ void* slsDetectorUtils::processData(int delflag) { if (*correctionMask&(1<< ANGULAR_CONVERSION)) { #ifdef VERBOSE - cout << "**************Current position index is " << currentPositionIndex << endl; + // cout << "**************Current position index is " << currentPositionIndex << endl; #endif if (currentPositionIndex<=1) { if (*binSize>0) @@ -1745,7 +1751,7 @@ void* slsDetectorUtils::processData(int delflag) { nb=(int)(360./bs)+1; #ifdef VERBOSE - cout << "creating merging arrays "<< nb << endl; + // cout << "creating merging arrays "<< nb << endl; #endif mergingBins=new float[nb]; mergingCounts=new float[nb]; @@ -1757,14 +1763,14 @@ void* slsDetectorUtils::processData(int delflag) { #endif #ifdef VERBOSE - cout << "reset merging " << endl; + // cout << "reset merging " << endl; #endif resetMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs); } /* it would be better to create an ang0 with 0 encoder position and add to merging/write to file simply specifying that offset so that when it cycles writing the data or adding to merging it also calculates the angular position */ #ifdef VERBOSE - cout << "convert angles" << endl; + // cout << "convert angles" << endl; #endif ang=convertAngles(currentPosition); @@ -1773,14 +1779,14 @@ void* slsDetectorUtils::processData(int delflag) { //uses static function?!?!?!? //writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang); #ifdef VERBOSE - cout << "Write angular converted file for position " << currentPositionIndex << endl; + // cout << "Write angular converted file for position " << currentPositionIndex << endl; #endif writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang); } } #ifdef VERBOSE - cout << "add to merging "<< currentPositionIndex << endl; + // cout << "add to merging "<< currentPositionIndex << endl; #endif addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask ); @@ -1796,82 +1802,68 @@ void* slsDetectorUtils::processData(int delflag) { // if ((currentPositionIndex>=(*numberOfPositions)) || (currentPositionIndex==0)) { #ifdef VERBOSE - cout << "finalize merging " << currentPositionIndex<< endl; + // cout << "finalize merging " << currentPositionIndex<< endl; #endif np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs); /** file writing */ - // pthread_mutex_lock(&mp); - // if (currentPositionIndex==(*numberOfPositions) && posfinished==1 && queuesize==1) { - - //cout << "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP Incrementing positon index " << endl; - - currentPositionIndex++; - // } pthread_mutex_unlock(&mp); fname=createFileName(); -//if (*correctionMask!=0) { ///////is this necessary?!?!?!? - //uses static function?!?!?!? #ifdef VERBOSE - cout << "writing merged data file" << endl; + // cout << "writing merged data file" << endl; #endif writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f'); #ifdef VERBOSE - cout << " done" << endl; + // cout << " done" << endl; #endif - //} -// if ((*numberOfPositions)==0) -// currentPositionIndex--; - if (delflag) { #ifdef VERBOSE - cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl; + // cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl; #endif if (mergingBins) { #ifdef VERBOSE - cout << "deleting merged bins "<< mergingBins << " size " << sizeof(mergingBins) << endl; + // cout << "deleting merged bins "<< mergingBins << " size " << sizeof(mergingBins) << endl; #endif delete [] mergingBins; mergingBins=NULL; } if (mergingCounts) { #ifdef VERBOSE - cout << "deleting merged counts "<< mergingCounts << endl; + // cout << "deleting merged counts "<< mergingCounts << endl; #endif delete [] mergingCounts; mergingCounts=NULL; } if (mergingErrors) { #ifdef VERBOSE - cout << "deleting merged errors "<< mergingErrors << endl; + // cout << "deleting merged errors "<< mergingErrors << endl; #endif delete [] mergingErrors; mergingErrors=NULL; } if (mergingMultiplicity){ #ifdef VERBOSE - cout << "deleting merged multiplicity "<