mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
added callbacks (but should still implement them in the base classes)
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@182 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -11,7 +11,8 @@ using namespace std;
|
||||
angularConversion::angularConversion(): currentPosition(0),
|
||||
currentPositionIndex(0)
|
||||
{
|
||||
|
||||
//angleFunctionPointer=0;
|
||||
registerAngleFunctionCallback(&defaultAngleFunction);
|
||||
|
||||
}
|
||||
|
||||
|
@ -436,6 +436,13 @@ class angularConversion : public virtual slsDetectorBase {
|
||||
int getCurrentPositionIndex() {return currentPositionIndex;};
|
||||
void incrementPositionIndex() {currentPositionIndex++;};
|
||||
|
||||
|
||||
|
||||
|
||||
void registerAngleFunctionCallback(float( *fun)(float, float, float, float, float, float, float, int)) {angle = fun;};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/** merging bins */
|
||||
float *mergingBins;
|
||||
@ -449,7 +456,7 @@ class angularConversion : public virtual slsDetectorBase {
|
||||
/** merging multiplicity */
|
||||
int *mergingMultiplicity;
|
||||
|
||||
|
||||
float (*angle)(float, float, float, float, float, float, float, int);
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
|
||||
#ifndef DETECTOR_DATA_H
|
||||
#define DETECTOR_DATA_H
|
||||
/**
|
||||
@short data structure to hold the detector data after postprocessing
|
||||
|
||||
@ -32,3 +33,5 @@ class detectorData {
|
||||
int npoints;/**< number of points */
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "postProcessing.h"
|
||||
#include "usersFunctions.h"
|
||||
|
||||
|
||||
postProcessing::postProcessing(){
|
||||
@ -7,6 +8,10 @@ postProcessing::postProcessing(){
|
||||
pthread_mutex_init(&mp, NULL);
|
||||
mg=mp1;
|
||||
pthread_mutex_init(&mg, NULL);
|
||||
//cout << "reg callback "<< endl;
|
||||
dataReady = 0;
|
||||
registerDataCallback(&defaultDataReadyFunc);
|
||||
//cout << "done "<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -164,11 +169,14 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
||||
void postProcessing::doProcessing(float *lfdata, int delflag, string fname) {
|
||||
|
||||
|
||||
/** write raw data file */
|
||||
if (*correctionMask==0 && delflag==1) {
|
||||
// delete [] fdata;
|
||||
;
|
||||
} else {
|
||||
// /** write raw data file */
|
||||
// if (*correctionMask==0 && delflag==1) {
|
||||
// // delete [] fdata;
|
||||
|
||||
|
||||
|
||||
// ;
|
||||
// } else {
|
||||
|
||||
|
||||
|
||||
@ -278,17 +286,25 @@ void postProcessing::doProcessing(float *lfdata, int delflag, string fname) {
|
||||
|
||||
|
||||
|
||||
if (delflag) {
|
||||
deleteMerging();
|
||||
} else {
|
||||
// if (delflag) {
|
||||
// deleteMerging();
|
||||
// } else {
|
||||
thisData=new detectorData(getMergedCounts(),getMergedErrors(),getMergedPositions(),getCurrentProgress(),(fname+ext).c_str(),np);
|
||||
|
||||
// cout << "lock 2" << endl;
|
||||
pthread_mutex_lock(&mg);
|
||||
finalDataQueue.push(thisData);
|
||||
// cout << "unlock 2" << endl;
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
// // cout << "lock 2" << endl;
|
||||
// pthread_mutex_lock(&mg);
|
||||
// finalDataQueue.push(thisData);
|
||||
// // cout << "unlock 2" << endl;
|
||||
|
||||
// pthread_mutex_unlock(&mg);
|
||||
|
||||
if (dataReady) {
|
||||
|
||||
dataReady(thisData);
|
||||
delete thisData;
|
||||
}
|
||||
|
||||
// }
|
||||
// cout << "lock 3" << endl;
|
||||
pthread_mutex_lock(&mp);
|
||||
}
|
||||
@ -309,21 +325,29 @@ void postProcessing::doProcessing(float *lfdata, int delflag, string fname) {
|
||||
ang=NULL;
|
||||
|
||||
} else {
|
||||
if (delflag) {
|
||||
if (ffcdata)
|
||||
delete [] ffcdata;
|
||||
if (ffcerr)
|
||||
delete [] ffcerr;
|
||||
if ( ang)
|
||||
delete [] ang;
|
||||
} else {
|
||||
// if (delflag) {
|
||||
// if (ffcdata)
|
||||
// delete [] ffcdata;
|
||||
// if (ffcerr)
|
||||
// delete [] ffcerr;
|
||||
// if ( ang)
|
||||
// delete [] ang;
|
||||
// } else {
|
||||
thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+ext).c_str(),getTotalNumberOfChannels());
|
||||
pthread_mutex_lock(&mg);
|
||||
finalDataQueue.push(thisData);
|
||||
pthread_mutex_unlock(&mg);
|
||||
}
|
||||
|
||||
|
||||
if (dataReady) {
|
||||
dataReady(thisData);
|
||||
delete thisData;
|
||||
}
|
||||
// pthread_mutex_lock(&mg);
|
||||
// finalDataQueue.push(thisData);
|
||||
|
||||
|
||||
// pthread_mutex_unlock(&mg);
|
||||
// }
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
incrementFileIndex();
|
||||
#ifdef VERBOSE
|
||||
|
@ -243,7 +243,8 @@ s
|
||||
|
||||
|
||||
|
||||
|
||||
void registerDataCallback(int( *userCallback)(detectorData*)) {dataReady = userCallback;};
|
||||
|
||||
|
||||
|
||||
|
||||
@ -363,7 +364,8 @@ s
|
||||
/* virtual float* decodeData(int *datain, float *fdata=NULL)=0; */
|
||||
/* virtual int getTotalNumberOfChannels()=0; */
|
||||
|
||||
|
||||
|
||||
int (*dataReady)(detectorData*);
|
||||
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user