Merge branch 'master' of gitorious.psi.ch:sls_det_software/sls_detector_software

This commit is contained in:
2015-09-24 10:54:48 +02:00
22 changed files with 539 additions and 266 deletions

View File

@ -47,7 +47,6 @@ int energyConversion::readCalibrationFile(string fname, double &gain, double &of
int energyConversion::writeCalibrationFile(string fname, double gain, double offset){
//std::cout<< "Function not yet implemented " << std::endl;
ofstream outfile;
outfile.open (fname.c_str());
// >> i/o operations here <<
@ -70,66 +69,62 @@ int energyConversion::writeCalibrationFile(string fname, double gain, double off
};
int energyConversion::readCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType){
int energyConversion::readCalibrationFile(string fname, int *gain, int *offset, detectorType myDetectorType){
string str;
ifstream infile;
double o,g;
int ig=0;
switch (myDetectorType) {
case EIGER:
string str;
ifstream infile;
double o,g;
int ig=0;
switch (myDetectorType) {
case EIGER:
#ifdef VERBOSE
std::cout<< "Opening file "<< fname << std::endl;
std::cout<< "Opening file "<< fname << std::endl;
#endif
infile.open(fname.c_str(), ios_base::in);
if (infile.is_open()) {
for (ig=0; ig<4; ig++) {
//while ( (getline(infile,str)) > -1) {
getline(infile,str);
infile.open(fname.c_str(), ios_base::in);
if (infile.is_open()) {
for (ig=0; ig<4; ig++) {
//while ( (getline(infile,str)) > -1) {
getline(infile,str);
#ifdef VERBOSE
std::cout<< str << std::endl;
std::cout<< str << std::endl;
#endif
istringstream ssstr(str);
ssstr >> o >> g;
offset[ig]=o;
gain[ig]=g;
// ig++;
if (ig>=4)
break;
}
infile.close();
cout << "Calibration file loaded: " << fname << endl;
} else {
std::cout<< "Could not open calibration file "<< fname << std::endl;
gain[0]=0.;
offset[0]=0.;
istringstream ssstr(str);
ssstr >> o >> g;
offset[ig]=(int)(o*1000);
gain[ig]=(int)(g*1000);
// ig++;
if (ig>=4)
break;
}
infile.close();
cout << "Calibration file loaded: " << fname << endl;
} else {
cout << "Could not open calibration file: "<< fname << std::endl;
gain[0]=0;
offset[0]=0;
#ifndef MYROOT
return FAIL;
return FAIL;
#endif
return -1;
}
return -1;
}
#ifndef MYROOT
return OK;
return OK;
#endif
return 0;
break;
default:
return readCalibrationFile(fname, *gain, *offset);
}
return 0;
break;
default:
std::cout<< "Writing Calibration Files for this detector not defined\n" << std::endl;
return FAIL;
}
};
int energyConversion::writeCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType){
int energyConversion::writeCalibrationFile(string fname, int *gain, int *offset, detectorType myDetectorType){
//std::cout<< "Function not yet implemented " << std::endl;
ofstream outfile;
switch (myDetectorType) {
@ -140,7 +135,7 @@ int energyConversion::writeCalibrationFile(string fname, double *gain, double *o
// >> i/o operations here <<
if (outfile.is_open()) {
for (int ig=0; ig<4; ig++)
outfile << offset[ig] << " " << gain[ig] << std::endl;
outfile << ((double)offset[ig]/1000) << " " << ((double)gain[ig]/1000) << std::endl;
} else {
std::cout<< "Could not open calibration file "<< fname << " for writing" << std::endl;
#ifndef MYROOT
@ -156,7 +151,8 @@ int energyConversion::writeCalibrationFile(string fname, double *gain, double *o
return 0;
break;
default:
return writeCalibrationFile(fname, *gain, *offset);
std::cout<< "Writing Calibration Files for this detector not defined\n" << std::endl;
return FAIL;
}
};

View File

@ -54,7 +54,7 @@ class energyConversion
\param gain reference to the gain variable
\offset reference to the offset variable
*/
static int readCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType);
static int readCalibrationFile(string fname, int *gain, int *offset, detectorType myDetectorType);
/**
writes a calibration file
@ -62,7 +62,7 @@ class energyConversion
\param gain
\param offset
*/
static int writeCalibrationFile(string fname, double *gain, double *offset, detectorType myDetectorType);
static int writeCalibrationFile(string fname, int *gain, int *offset, detectorType myDetectorType);

View File

@ -138,7 +138,7 @@ void postProcessing::processFrame(int *myData, int delflag, int jctb) {
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+string(".raw")).c_str() << " " << getTotalNumberOfChannels() << endl;
// cout << "DATAREADY 1" <<endl;
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels());
dataReady(thisData, currentFrameIndex, pCallbackArg);
dataReady(thisData, currentFrameIndex, -1, pCallbackArg);
delete thisData;
fdata=NULL;
}
@ -281,7 +281,7 @@ data queue size unlock
// cout << "callback arg "<< getCurrentProgress()<< " " << (fname+ext).c_str() << " " << np << endl;
//cout << "ADATREADY 2 " << endl;
thisData=new detectorData(val,err,ang,getCurrentProgress(),(fname+ext).c_str(),np);
dataReady(thisData, currentFrameIndex, pCallbackArg);
dataReady(thisData, currentFrameIndex, -1, pCallbackArg);
delete thisData;
ang=NULL;
val=NULL;
@ -500,6 +500,7 @@ void* postProcessing::processData(int delflag) {
int caught = -1;
int currentAcquisitionIndex = -1;
int currentFrameIndex = -1;
int currentSubFrameIndex = -1;
bool newData = false;
int nthframe = setReadReceiverFrequency(0);
@ -633,7 +634,7 @@ void* postProcessing::processData(int delflag) {
strcpy(currentfName,"");
pthread_mutex_lock(&mg);
//int* receiverData = new int [getTotalNumberOfChannels()];
int* receiverData = readFrameFromReceiver(currentfName,currentAcquisitionIndex,currentFrameIndex);
int* receiverData = readFrameFromReceiver(currentfName,currentAcquisitionIndex,currentFrameIndex,currentSubFrameIndex);
pthread_mutex_unlock(&mg);
//if detector returned null
@ -664,7 +665,7 @@ void* postProcessing::processData(int delflag) {
if ((fdata) && (dataReady)){
// cout << "DATAREADY 3" << endl;
thisData = new detectorData(fdata,NULL,NULL,getCurrentProgress(),currentfName,getTotalNumberOfChannels());
dataReady(thisData, currentFrameIndex, pCallbackArg);
dataReady(thisData, currentFrameIndex, currentSubFrameIndex, pCallbackArg);
delete thisData;
fdata = NULL;
progress = caught;

View File

@ -238,7 +238,7 @@ s
void ResetPositionIndex(){pthread_mutex_lock(&mp); resetPositionIndex(); pthread_mutex_unlock(&mp);};
void registerDataCallback(int( *userCallback)(detectorData*, int, void*), void *pArg) {dataReady = userCallback; pCallbackArg = pArg;};
void registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg) {dataReady = userCallback; pCallbackArg = pArg;};
void registerRawDataCallback(int( *userCallback)(double*, int, void*), void *pArg) {rawDataReady = userCallback; pRawDataArg = pArg;};
@ -335,7 +335,7 @@ s
private:
double *fdata;
int (*dataReady)(detectorData*,int, void*);
int (*dataReady)(detectorData*,int, int,void*);
void *pCallbackArg;
int (*rawDataReady)(double*,int,void*);