diff --git a/slsDetectorSoftware/mythenDetector/mythenDetector.h b/slsDetectorSoftware/mythenDetector/mythenDetector.h
index fc6f1b7af..b53b7c282 100644
--- a/slsDetectorSoftware/mythenDetector/mythenDetector.h
+++ b/slsDetectorSoftware/mythenDetector/mythenDetector.h
@@ -38,124 +38,5 @@ class mythenDetector : public slsDetector{
-
- /**
- reads configuration file fname calling executeLine
- \param fname file to be read
- */
- int readConfigurationFile(string const fname);
- /**
- writes configuration file calling executeLine
- \param fname file to write to
- */
- int writeConfigurationFile(string const fname);
- /**
- dumps all the possible detector parameters calling executeLine
- \param fname file to write to
- \param level 0 dumps only main parameters and filenames for flat field correction etc.; 2 dumps really the complete configuration including flat field files, badchannels files, trimbits, angular conversion etc.
- */
- int dumpDetectorSetup(string const fname, int level=0);
- /**
- retrieves all possible detector parameters from file calling executeLine
- \param fname file to be read
- */
- int retrieveDetectorSetup(string const fname, int level=0);
-
- /**
- reads a trim/settings file
- \param fname name of the file to be read
- \param myMod pointer to the module structure which has to be set.
If it is NULL a new module structure will be created
- \returns the pointer to myMod or NULL if reading the file failed
- */
-
- sls_detector_module* readSettingsFile(string fname, sls_detector_module* myMod=NULL);
-
- /**
- writes a trim/settings file
- \param fname name of the file to be written
- \param mod module structure which has to be written to file
- \returns OK or FAIL if the file could not be written
-
- \sa ::sls_detector_module
- */
- int writeSettingsFile(string fname, sls_detector_module mod);
-
- /**
- writes a trim/settings file for module number imod - the values will be read from the current detector structure
- \param fname name of the file to be written
- \param imod module number
- \returns OK or FAIL if the file could not be written
- \sa ::sls_detector_module sharedSlsDetector
- */
- int writeSettingsFile(string fname, int imod);
-
- /**
- writes a data file
- \param name of the file to be written
- \param data array of data values
- \param err array of arrors on the data. If NULL no errors will be written
-
- \param ang array of angular values. If NULL data will be in the form chan-val(-err) otherwise ang-val(-err)
- \param dataformat format of the data: can be 'i' integer or 'f' float (default)
- \param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector
- \returns OK or FAIL if it could not write the file or data=NULL
-
-
- */
- int writeDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=-1);
-
- /**
- writes a data file
- \param name of the file to be written
- \param data array of data values
- \returns OK or FAIL if it could not write the file or data=NULL
- */
- int writeDataFile(string fname, int *data);
-
- /**
- reads a data file
- \param name of the file to be read
- \param data array of data values to be filled
- \param err array of arrors on the data. If NULL no errors are expected on the file
-
- \param ang array of angular values. If NULL data are expected in the form chan-val(-err) otherwise ang-val(-err)
- \param dataformat format of the data: can be 'i' integer or 'f' float (default)
- \param nch number of channels to be written to file. if <=0 defaults to the number of installed channels of the detector
- \returns OK or FAIL if it could not read the file or data=NULL
-
-
- */
- int readDataFile(string fname, float *data, float *err=NULL, float *ang=NULL, char dataformat='f', int nch=0);
-
- /**
- reads a data file
- \param name of the file to be read
- \param data array of data values
- \returns OK or FAIL if it could not read the file or data=NULL
- */
- int readDataFile(string fname, int *data);
-
-
- /**
- reads a calibration file
- \param fname file to be read
- \param gain reference to the gain variable
- \offset reference to the offset variable
- \sa sharedSlsDetector
- */
- int readCalibrationFile(string fname, float &gain, float &offset);
- /**
- writes a clibration file
- \param fname file to be written
- \param gain
- \param offset
- \sa sharedSlsDetector
- */
- int writeCalibrationFile(string fname, float gain, float offset);
-
-
-
-
-
};
#endif
diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp
index fd5198379..1c87655c5 100644
--- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp
+++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.cpp
@@ -1685,6 +1685,277 @@ void slsDetectorUtils::acquire(int delflag){
}
+
+
+
+
+
+
+
+
+
+void slsDetectorUtils::processFrame(int *myData, int delflag) {
+
+ string fname;
+ float *fdata;
+
+ progressIndex++;
+ //#ifdef VERBOSE
+ cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%";
+#ifdef VERBOSE
+ cout << endl;
+#else
+ cout << "\r" << flush;
+#endif
+
+ //process data
+ /** decode data */
+ fdata=decodeData(myData);
+
+ fname=createFileName();
+
+
+ //uses static function?!?!?!?
+ // writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
+ writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
+
+ doProcessing(fdata,delflag);
+
+ delete [] myData;
+ myData=NULL;
+#ifdef VERBOSE
+ // cout << "Pop data queue " << *fileIndex << endl;
+#endif
+
+ pthread_mutex_lock(&mp);
+ dataQueue.pop(); //remove the data from the queue
+ queuesize=dataQueue.size();
+ pthread_mutex_unlock(&mp);
+
+
+}
+
+
+
+void slsDetectorUtils::doProcessing(float *fdata, int delflag) {
+
+
+ float *rcdata=NULL, *rcerr=NULL;
+ float *ffcdata=NULL, *ffcerr=NULL;
+ float *ang=NULL;
+ float bs=0.004;
+ // int imod;
+ int nb;
+ int np;
+ string ext;
+ string fname;
+ detectorData *thisData;
+
+
+
+ if (*correctionMask!=0) {
+ ext=".dat";
+ } else {
+ ext=".raw";
+ }
+
+ fname=createFileName();
+
+ /** write raw data file */
+ if (*correctionMask==0 && delflag==1) {
+ delete [] fdata;
+ } else {
+
+ /** rate correction */
+ if (*correctionMask&(1<0) {
+#ifdef VERBOSE
+ cout << "**************Current position index is " << currentPositionIndex << endl;
+#endif
+ // if (*numberOfPositions>0) {
+ if (currentPositionIndex<=1) {
+ if (*binSize>0)
+ bs=*binSize;
+ else
+ *binSize=bs;
+
+
+ nb=(int)(360./bs)+1;
+
+#ifdef VERBOSE
+ cout << "creating merging arrays "<< nb << endl;
+#endif
+ mergingBins=new float[nb];
+ mergingCounts=new float[nb];
+ mergingErrors=new float[nb];
+ mergingMultiplicity=new int[nb];
+#ifdef VERBOSE
+ cout << "reset merging " << endl;
+#endif
+ resetMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
+ }
+
+#ifdef VERBOSE
+ cout << "add to merging "<< currentPositionIndex << endl;
+#endif
+ addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask );
+
+#ifdef VERBOSE
+ cout << currentPositionIndex << " " << (*numberOfPositions) << endl;
+
+#endif
+
+
+ pthread_mutex_lock(&mp);
+ if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) {
+
+#ifdef VERBOSE
+ cout << "finalize merging " << currentPositionIndex<< endl;
+#endif
+ np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
+ /** file writing */
+
+ currentPositionIndex++;
+ pthread_mutex_unlock(&mp);
+
+
+ fname=createFileName();
+
+#ifdef VERBOSE
+ cout << "writing merged data file" << endl;
+#endif
+ writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f');
+#ifdef VERBOSE
+ cout << " done" << endl;
+#endif
+
+
+
+ if (delflag) {
+
+ if (mergingBins) {
+ delete [] mergingBins;
+ mergingBins=NULL;
+ }
+ if (mergingCounts) {
+ delete [] mergingCounts;
+ mergingCounts=NULL;
+ }
+ if (mergingErrors) {
+ delete [] mergingErrors;
+ mergingErrors=NULL;
+ }
+ if (mergingMultiplicity){
+ delete [] mergingMultiplicity;
+ mergingMultiplicity=NULL;
+ }
+#ifdef VERBOSE
+ cout << "deleting merged data done " << endl;
+#endif
+ } else {
+ thisData=new detectorData(mergingCounts,mergingErrors,mergingBins,getCurrentProgress(),(fname+string(ext)).c_str(),np);
+
+ pthread_mutex_lock(&mg);
+ finalDataQueue.push(thisData);
+ pthread_mutex_unlock(&mg);
+ }
+ pthread_mutex_lock(&mp);
+ }
+ pthread_mutex_unlock(&mp);
+
+
+
+
+ if (ffcdata)
+ delete [] ffcdata;
+ ffcdata=NULL;
+
+ if (ffcerr)
+ delete [] ffcerr;
+ ffcerr=NULL;
+ if (ang)
+ delete [] ang;
+ ang=NULL;
+
+ } else {
+ if (delflag) {
+ if (ffcdata)
+ delete [] ffcdata;
+ if (ffcerr)
+ delete [] ffcerr;
+ if ( ang)
+ delete [] ang;
+ } else {
+ thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+string(ext)).c_str(),getTotalNumberOfChannels());
+ pthread_mutex_lock(&mg);
+ finalDataQueue.push(thisData);
+ pthread_mutex_unlock(&mg);
+ }
+ }
+ }
+ (*fileIndex)++;
+#ifdef VERBOSE
+ cout << "Incrementing file index " << *fileIndex << endl;
+#endif
+
+
+}
+
+
+
+
+
+
+
+
void* slsDetectorUtils::processData(int delflag) {
@@ -1700,26 +1971,21 @@ void* slsDetectorUtils::processData(int delflag) {
//cout << "thread mutex unlock line 6505" << endl;
int *myData;
- float *fdata=NULL;
- float *rcdata=NULL, *rcerr=NULL;
- float *ffcdata=NULL, *ffcerr=NULL;
- float *ang=NULL;
- float bs=0.004;
- // int imod;
- int nb;
- int np;
- detectorData *thisData;
+// float *fdata=NULL;
+// float *rcdata=NULL, *rcerr=NULL;
+// float *ffcdata=NULL, *ffcerr=NULL;
+// float *ang=NULL;
+// float bs=0.004;
+// // int imod;
+// int nb;
+// int np;
+// detectorData *thisData;
int dum=1;
- string ext;
- string fname;
+// string ext;
+// string fname;
- if (*correctionMask!=0) {
- ext=".dat";
- } else {
- ext=".raw";
- }
while(dum | *threadedProcessing) { // ????????????????????????
@@ -1742,276 +2008,276 @@ void* slsDetectorUtils::processData(int delflag) {
if (myData) {
-
+ processFrame(myData,delflag);
- progressIndex++;
- //#ifdef VERBOSE
- cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%";
-#ifdef VERBOSE
- cout << endl;
-#else
- cout << "\r" << flush;
-#endif
+// progressIndex++;
+// //#ifdef VERBOSE
+// cout << fixed << setprecision(2) << setw (6) << getCurrentProgress() << " \%";
+// #ifdef VERBOSE
+// cout << endl;
+// #else
+// cout << "\r" << flush;
+// #endif
- //process data
- /** decode data */
- fdata=decodeData(myData);
+// //process data
+// /** decode data */
+// fdata=decodeData(myData);
- fname=createFileName();
+// fname=createFileName();
- //uses static function?!?!?!?
- // writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
- writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
+// //uses static function?!?!?!?
+// // writeDataFile (fname+string(".raw"), getTotalNumberOfChannels(),fdata, NULL, NULL, 'i');
+// writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
- /** write raw data file */
- if (*correctionMask==0 && delflag==1) {
- delete [] fdata;
- } else {
+// /** write raw data file */
+// if (*correctionMask==0 && delflag==1) {
+// delete [] fdata;
+// } else {
- /** rate correction */
- if (*correctionMask&(1<0 || delflag==0) {
+// if (*numberOfPositions>0 || delflag==0) {
- if (currentPositionIndex<=1) {
- if (*binSize>0)
- bs=*binSize;
- else
- *binSize=bs;
+// if (currentPositionIndex<=1) {
+// if (*binSize>0)
+// bs=*binSize;
+// else
+// *binSize=bs;
- nb=(int)(360./bs)+1;
+// nb=(int)(360./bs)+1;
-#ifdef VERBOSE
- // cout << "creating merging arrays "<< nb << endl;
-#endif
- mergingBins=new float[nb];
- mergingCounts=new float[nb];
- mergingErrors=new float[nb];
- mergingMultiplicity=new int[nb];
+// #ifdef VERBOSE
+// // cout << "creating merging arrays "<< nb << endl;
+// #endif
+// mergingBins=new float[nb];
+// mergingCounts=new float[nb];
+// mergingErrors=new float[nb];
+// mergingMultiplicity=new int[nb];
-#ifdef VERBOSE
- cout << mergingBins<< " "<< mergingCounts<< " "<< mergingErrors<< " "<< mergingMultiplicity<< " " << endl;
-#endif
+// #ifdef VERBOSE
+// cout << mergingBins<< " "<< mergingCounts<< " "<< mergingErrors<< " "<< mergingMultiplicity<< " " << endl;
+// #endif
-#ifdef VERBOSE
- // 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 << "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;
-#endif
- ang=convertAngles(currentPosition);
+// #ifdef VERBOSE
+// // cout << "convert angles" << endl;
+// #endif
+// ang=convertAngles(currentPosition);
- // if (*correctionMask!=0) {
- // if (*numberOfPositions>1) {
- //uses static function?!?!?!?
- //writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang);
-#ifdef VERBOSE
- // cout << "Write angular converted file for position " << currentPositionIndex << endl;
-#endif
+// // if (*correctionMask!=0) {
+// // if (*numberOfPositions>1) {
+// //uses static function?!?!?!?
+// //writeDataFile (fname+string(".dat"), getTotalNumberOfChannels(), ffcdata, ffcerr,ang);
+// #ifdef VERBOSE
+// // 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;
-#endif
- if (*numberOfPositions>0 || delflag==0) {
- addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask );
+// writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang);
+// // }
+// // }
+// #ifdef VERBOSE
+// // cout << "add to merging "<< currentPositionIndex << endl;
+// #endif
+// if (*numberOfPositions>0 || delflag==0) {
+// addToMerging(ang, ffcdata, ffcerr, mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, getTotalNumberOfChannels(), bs, *angDirection, *correctionMask, badChannelMask );
-#ifdef VERBOSE
- cout << currentPositionIndex << " " << (*numberOfPositions) << endl;
+// #ifdef VERBOSE
+// cout << currentPositionIndex << " " << (*numberOfPositions) << endl;
-#endif
+// #endif
- pthread_mutex_lock(&mp);
- if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) {
+// pthread_mutex_lock(&mp);
+// if ((currentPositionIndex>=(*numberOfPositions) && posfinished==1 && queuesize==1)) {
- // if ((currentPositionIndex>=(*numberOfPositions)) || (currentPositionIndex==0)) {
-#ifdef VERBOSE
- // cout << "finalize merging " << currentPositionIndex<< endl;
-#endif
- np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
- /** file writing */
+// // if ((currentPositionIndex>=(*numberOfPositions)) || (currentPositionIndex==0)) {
+// #ifdef VERBOSE
+// // cout << "finalize merging " << currentPositionIndex<< endl;
+// #endif
+// np=finalizeMerging(mergingBins, mergingCounts,mergingErrors, mergingMultiplicity, bs);
+// /** file writing */
- currentPositionIndex++;
- pthread_mutex_unlock(&mp);
+// currentPositionIndex++;
+// pthread_mutex_unlock(&mp);
- fname=createFileName();
+// fname=createFileName();
-#ifdef VERBOSE
- // cout << "writing merged data file" << endl;
-#endif
- writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f');
-#ifdef VERBOSE
- // cout << " done" << endl;
-#endif
+// #ifdef VERBOSE
+// // cout << "writing merged data file" << endl;
+// #endif
+// writeDataFile (fname+string(".dat"),np,mergingCounts, mergingErrors, mergingBins,'f');
+// #ifdef VERBOSE
+// // cout << " done" << endl;
+// #endif
- if (delflag) {
-#ifdef VERBOSE
- // cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
-#endif
+// if (delflag) {
+// #ifdef VERBOSE
+// // cout << mergingBins<< " " << mergingCounts<< " " << mergingErrors << " " << mergingMultiplicity << " " << endl;
+// #endif
- if (mergingBins) {
-#ifdef VERBOSE
- // cout << "deleting merged bins "<< mergingBins << " size " << sizeof(mergingBins) << endl;
-#endif
- delete [] mergingBins;
- mergingBins=NULL;
- }
- if (mergingCounts) {
-#ifdef VERBOSE
- // cout << "deleting merged counts "<< mergingCounts << endl;
-#endif
- delete [] mergingCounts;
- mergingCounts=NULL;
- }
- if (mergingErrors) {
-#ifdef VERBOSE
- // cout << "deleting merged errors "<< mergingErrors << endl;
-#endif
- delete [] mergingErrors;
- mergingErrors=NULL;
- }
- if (mergingMultiplicity){
-#ifdef VERBOSE
- // cout << "deleting merged multiplicity "<