mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 17:40:01 +02:00
some more changes in the acquisition function
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@172 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
ab4e569b6c
commit
1b6f8259c7
@ -401,3 +401,97 @@ int slsDetectorActions::getScanPrecision(int iscan){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int slsDetectorActions::executeScan(int level, int istep) {
|
||||||
|
|
||||||
|
int trimbit;
|
||||||
|
char cmd[MAX_STR_LENGTH];
|
||||||
|
|
||||||
|
if (level<0 || level>MAX_SCAN_LEVELS)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
currentScanVariable[level]=getScanStep(level,istep);
|
||||||
|
currentScanIndex[level]=istep;
|
||||||
|
|
||||||
|
switch(scanMode[level]) {
|
||||||
|
case 1:
|
||||||
|
setThresholdEnergy((int)currentScanVariable[level]); //energy scan
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
setDAC(currentScanVariable[level],THRESHOLD); // threshold scan
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
trimbit=(int)currentScanVariable[level];
|
||||||
|
setChannel((trimbit<<((int)TRIMBIT_OFF))|((int)COMPARATOR_ENABLE)); // trimbit scan
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
currentScanVariable[level]=0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//Custom scan script level 1. The arguments are passed as nrun=n fn=filename var=v par=p"
|
||||||
|
sprintf(cmd,"%s nrun=%d fn=%s var=%f par=%s",getScanScript(level).c_str(),*fileIndex,createFileName().c_str(),currentScanVariable[level],getScanParameter(level).c_str());
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Executing scan script "<< level << " " << cmd << endl;
|
||||||
|
#endif
|
||||||
|
system(cmd);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int slsDetectorActions::executeAction(int level) {
|
||||||
|
|
||||||
|
|
||||||
|
if (*actionMask & (1 << level)) {
|
||||||
|
|
||||||
|
char cmd[MAX_STR_LENGTH];
|
||||||
|
switch (level) {
|
||||||
|
case startScript:
|
||||||
|
case stopScript:
|
||||||
|
sprintf(cmd,"%s nrun=%d par=%s",getActionScript(level).c_str(),*fileIndex,getActionParameter(level).c_str());
|
||||||
|
break;
|
||||||
|
case scriptBefore:
|
||||||
|
case scriptAfter:
|
||||||
|
sprintf(cmd,"%s nrun=%d fn=%s par=%s sv0=%f sv1=%f p0=%s p1=%s",getActionScript(level).c_str(),*fileIndex,currentFileName.c_str(),getActionParameter(level).c_str(),currentScanVariable[0],currentScanVariable[1],getScanParameter(0).c_str(),getScanParameter(1).c_str());
|
||||||
|
break;
|
||||||
|
case headerBefore:
|
||||||
|
fName=currentFileName;
|
||||||
|
nowIndex=getFileIndexFromFileName(currentFileName);
|
||||||
|
case headerAfter:
|
||||||
|
// sprintf(cmd,"%s nrun=%d fn=%s acqtime=%f gainmode=%d threshold=%d badfile=%s angfile=%s bloffset=%f fineoffset=%f fffile=%s/%s tau=%f par=%s", \
|
||||||
|
// getActionScript(level).c_str(), \
|
||||||
|
// getFileIndexFromFileName(currentFileName), \
|
||||||
|
// currentFileName.c_str(), \
|
||||||
|
// ((float)timerValue[ACQUISITION_TIME])*1E-9, \
|
||||||
|
// *currentSettings, \
|
||||||
|
// *currentThresholdEV, \
|
||||||
|
// getBadChannelCorrectionFile().c_str(), \
|
||||||
|
// angularConversion::getAngularConversionFile().c_str(), \
|
||||||
|
// *globalOffset, \
|
||||||
|
// *fineOffset, \
|
||||||
|
// getFlatFieldCorrectionDir().c_str(), \
|
||||||
|
// getFlatFieldCorrectionFile().c_str(), \
|
||||||
|
// getRateCorrectionTau(), \
|
||||||
|
// getActionParameter(level).c_str());
|
||||||
|
|
||||||
|
// all other parameters should be taken using text client calls in the header scripts!
|
||||||
|
|
||||||
|
sprintf(cmd,"%s nrun=%d fn=%s par=%s", \
|
||||||
|
getActionScript(level).c_str(), \
|
||||||
|
nowIndex, \
|
||||||
|
fName.c_str(), \
|
||||||
|
getActionParameter(level).c_str());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strcpy(cmd,"");
|
||||||
|
}
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "Executing script "<< level << " " << cmd << endl;
|
||||||
|
#endif
|
||||||
|
system(cmd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "sls_detector_defs.h"
|
#include "postProcessing.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ using namespace std;
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class slsDetectorActions : public slsDetectorDefs {
|
class slsDetectorActions : public postProcessing {
|
||||||
public :
|
public :
|
||||||
/** default constructor */
|
/** default constructor */
|
||||||
slsDetectorActions(){};
|
slsDetectorActions(){};
|
||||||
@ -179,8 +179,35 @@ class slsDetectorActions : public slsDetectorDefs {
|
|||||||
float getCurrentScanVariable(int index) {return currentScanVariable[index];};
|
float getCurrentScanVariable(int index) {return currentScanVariable[index];};
|
||||||
// int getScanPrecision(int index) {return scanPrecision[index];};
|
// int getScanPrecision(int index) {return scanPrecision[index];};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
set dacs value
|
||||||
|
\param val value (in V)
|
||||||
|
\param index DAC index
|
||||||
|
\param imod module number (if -1 alla modules)
|
||||||
|
\returns current DAC value
|
||||||
|
*/
|
||||||
|
virtual float setDAC(float val, dacIndex index , int imod=-1)=0;
|
||||||
|
|
||||||
|
|
||||||
|
virtual int setThresholdEnergy(int, int im=-1, detectorSettings isettings=GET_SETTINGS)=0;
|
||||||
|
virtual int setChannel(long long, int ich=-1, int ichip=-1, int imod=-1)=0;
|
||||||
|
|
||||||
|
|
||||||
|
int setStartIndex(int i=-1){if (i>=0) {startIndex=i; lastIndex=startIndex; nowIndex=startIndex;};return startIndex;};
|
||||||
|
int setLastIndex(int i=-1){if (i>=0 && i>lastIndex) lastIndex=i; return lastIndex;};
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
int executeScan(int level, int istep);
|
||||||
|
int executeAction(int level);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** action mask */
|
/** action mask */
|
||||||
int *actionMask;
|
int *actionMask;
|
||||||
/** array of action scripts */
|
/** array of action scripts */
|
||||||
@ -222,6 +249,12 @@ class slsDetectorActions : public slsDetectorDefs {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int startIndex;
|
||||||
|
int lastIndex;
|
||||||
|
int nowIndex;
|
||||||
|
string fName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,31 +18,16 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Acquire function "<< delflag << endl;
|
cout << "Acquire function "<< delflag << endl;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Stopped flag is "<< stoppedFlag << delflag << endl;
|
cout << "Stopped flag is "<< stoppedFlag << delflag << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
posfinished=0;
|
|
||||||
|
|
||||||
|
|
||||||
void *status;
|
void *status;
|
||||||
int trimbit;
|
|
||||||
|
setStartIndex(*fileIndex);
|
||||||
|
|
||||||
|
// int lastindex=startindex, nowindex=startindex;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char cmd[MAX_STR_LENGTH];
|
|
||||||
int startindex=*fileIndex;
|
|
||||||
int nowindex=startindex, lastindex=startindex;
|
|
||||||
string fn;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//string sett;
|
|
||||||
if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION)))
|
if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION)))
|
||||||
connect_channels();
|
connect_channels();
|
||||||
|
|
||||||
@ -54,16 +39,14 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mp);
|
||||||
resetFinalDataQueue();
|
resetFinalDataQueue();
|
||||||
resetDataQueue();
|
resetDataQueue();
|
||||||
|
|
||||||
|
|
||||||
//cout << "main mutex lock line 6188" << endl;
|
|
||||||
pthread_mutex_lock(&mp);
|
|
||||||
jointhread=0;
|
jointhread=0;
|
||||||
queuesize=0;
|
queuesize=0;
|
||||||
|
posfinished=0;
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
//cout << "main mutex unlock line 6188" << endl;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -75,9 +58,6 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
startThread(delflag);
|
startThread(delflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//cout << "data thread started " << endl;
|
//cout << "data thread started " << endl;
|
||||||
int np=1;
|
int np=1;
|
||||||
if (*numberOfPositions>0)
|
if (*numberOfPositions>0)
|
||||||
@ -87,64 +67,30 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
if (*actionMask & (1 << MAX_ACTIONS)) {
|
if (*actionMask & (1 << MAX_ACTIONS)) {
|
||||||
ns0=nScanSteps[0];
|
ns0=nScanSteps[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ns0<1)
|
if (ns0<1)
|
||||||
ns0=1;
|
ns0=1;
|
||||||
|
|
||||||
|
|
||||||
int ns1=1;
|
int ns1=1;
|
||||||
if (*actionMask & (1 << (MAX_ACTIONS+1))) {
|
if (*actionMask & (1 << (MAX_ACTIONS+1))) {
|
||||||
ns1=nScanSteps[1];
|
ns1=nScanSteps[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ns1<1)
|
if (ns1<1)
|
||||||
ns1=1;
|
ns1=1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//cout << "action at start" << endl;
|
//cout << "action at start" << endl;
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
if (*actionMask & (1 << startScript)) {
|
executeAction(startScript);
|
||||||
//"Custom start script. The arguments are passed as nrun=n par=p.");
|
|
||||||
sprintf(cmd,"%s nrun=%d par=%s",getActionScript(startScript).c_str(),*fileIndex,getActionParameter(startScript).c_str());
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Executing start script " << cmd << endl;
|
|
||||||
#endif
|
|
||||||
system(cmd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int is0=0; is0<ns0; is0++) {
|
for (int is0=0; is0<ns0; is0++) {
|
||||||
// cout << "scan0 loop" << endl;
|
// cout << "scan0 loop" << endl;
|
||||||
|
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
|
executeScan(0,is0);
|
||||||
currentScanVariable[0]=getScanStep(0,is0);
|
|
||||||
currentScanIndex[0]=is0;
|
|
||||||
|
|
||||||
switch(scanMode[0]) {
|
|
||||||
case 1:
|
|
||||||
setThresholdEnergy((int)currentScanVariable[0]); //energy scan
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
setDAC(currentScanVariable[0],THRESHOLD); // threshold scan
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
trimbit=(int)currentScanVariable[0];
|
|
||||||
setChannel((trimbit<<((int)TRIMBIT_OFF))|((int)COMPARATOR_ENABLE)); // trimbit scan
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
currentScanVariable[0]=0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//Custom scan script level 0. The arguments are passed as nrun=n fn=filename var=v par=p"
|
|
||||||
sprintf(cmd,"%s nrun=%d fn=%s var=%f par=%s",getScanScript(0).c_str(),*fileIndex,createFileName().c_str(),currentScanVariable[0],getScanParameter(0).c_str());
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Executing scan script 0 " << cmd << endl;
|
|
||||||
#endif
|
|
||||||
system(cmd);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -153,45 +99,12 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
// cout << "scan1 loop" << endl;
|
// cout << "scan1 loop" << endl;
|
||||||
|
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
|
executeScan(1,is1);
|
||||||
currentScanVariable[1]=getScanStep(1,is1);
|
|
||||||
currentScanIndex[1]=is1;
|
|
||||||
|
|
||||||
switch(scanMode[1]) {
|
|
||||||
case 1:
|
|
||||||
setThresholdEnergy((int)currentScanVariable[1]); //energy scan
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
setDAC(currentScanVariable[1],THRESHOLD); // threshold scan
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
trimbit=(int)currentScanVariable[1];
|
|
||||||
setChannel((trimbit<<((int)TRIMBIT_OFF))|((int)COMPARATOR_ENABLE)); // trimbit scan
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
currentScanVariable[1]=0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//Custom scan script level 1. The arguments are passed as nrun=n fn=filename var=v par=p"
|
|
||||||
sprintf(cmd,"%s nrun=%d fn=%s var=%f par=%s",getScanScript(1).c_str(),*fileIndex,createFileName().c_str(),currentScanVariable[1],getScanParameter(1).c_str());
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Executing scan script 1 " << cmd << endl;
|
|
||||||
#endif
|
|
||||||
system(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
if (*actionMask & (1 << scriptBefore)) {
|
executeAction(scriptBefore);
|
||||||
//Custom script before each frame. The arguments are passed as nrun=n fn=filename par=p sv0=scanvar0 sv1=scanvar1 p0=par0 p1=par1"
|
|
||||||
sprintf(cmd,"%s nrun=%d fn=%s par=%s sv0=%f sv1=%f p0=%s p1=%s",getActionScript(scriptBefore).c_str(),*fileIndex,createFileName().c_str(),getActionParameter(scriptBefore).c_str(),currentScanVariable[0],currentScanVariable[1],getScanParameter(0).c_str(),getScanParameter(1).c_str());
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Executing script before " << cmd << endl;
|
|
||||||
#endif
|
|
||||||
system(cmd);
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -210,47 +123,9 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//write header before?
|
|
||||||
//cmd=headerBeforeScript;
|
|
||||||
//Custom script to write the header. \n The arguments will be passed as nrun=n fn=filenam acqtime=t gainmode=g threshold=thr badfile=badf angfile=angf bloffset=blo fineoffset=fo fffile=fffn tau=deadtau par=p")
|
|
||||||
|
|
||||||
// cout << "aaaaa" << endl;
|
|
||||||
//cout << createFileName() << endl;
|
|
||||||
//cout << "bbbbb" << endl;
|
|
||||||
fn=createFileName();
|
|
||||||
//cout << fn << endl;
|
|
||||||
nowindex=*fileIndex;
|
|
||||||
|
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
|
executeAction(scriptBefore);
|
||||||
|
|
||||||
if (*correctionMask&(1<< I0_NORMALIZATION))
|
|
||||||
currentI0=get_i0();
|
|
||||||
|
|
||||||
// cout << "header " << endl;
|
|
||||||
if (*actionMask & (1 << headerBefore)) {
|
|
||||||
//Custom script after each frame. The arguments are passed as nrun=n fn=filename par=p sv0=scanvar0 sv1=scanvar1 p0=par0 p1=par1"
|
|
||||||
sprintf(cmd,"%s nrun=%d fn=%s acqtime=%f gainmode=%d threshold=%d badfile=%s angfile=%s bloffset=%f fineoffset=%f fffile=%s/%s tau=%f par=%s",\
|
|
||||||
getActionScript(headerBefore).c_str(),\
|
|
||||||
nowindex,\
|
|
||||||
fn.c_str(), \
|
|
||||||
((float)timerValue[ACQUISITION_TIME])*1E-9, \
|
|
||||||
*currentSettings, \
|
|
||||||
*currentThresholdEV, \
|
|
||||||
getBadChannelCorrectionFile().c_str(), \
|
|
||||||
angularConversion::getAngularConversionFile().c_str(), \
|
|
||||||
*globalOffset, \
|
|
||||||
*fineOffset,\
|
|
||||||
getFlatFieldCorrectionDir().c_str(),\
|
|
||||||
getFlatFieldCorrectionFile().c_str(), \
|
|
||||||
getRateCorrectionTau(),\
|
|
||||||
getActionParameter(headerBefore).c_str()\
|
|
||||||
);
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Executing header before " << cmd << endl;
|
|
||||||
#endif
|
|
||||||
system(cmd);
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -258,6 +133,8 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
|
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
|
|
||||||
|
executeAction(headerBefore);
|
||||||
|
|
||||||
if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
if (*correctionMask&(1<< ANGULAR_CONVERSION)) {
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
currentPosition=get_position();
|
currentPosition=get_position();
|
||||||
@ -265,26 +142,20 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*correctionMask&(1<< I0_NORMALIZATION))
|
||||||
|
get_i0(0);
|
||||||
|
|
||||||
// cout << "starting???? " << endl;
|
|
||||||
startAndReadAll();
|
startAndReadAll();
|
||||||
|
|
||||||
|
if (*correctionMask&(1<< I0_NORMALIZATION))
|
||||||
|
currentI0=get_i0(1); // this is the correct i0!!!!!
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
posfinished=1;
|
posfinished=1;
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "returned " << endl;
|
|
||||||
pthread_mutex_lock(&mp);
|
|
||||||
cout << "AAAA queue size " << dataQueue.size()<< endl;
|
|
||||||
pthread_mutex_unlock(&mp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
if (*correctionMask&(1<< I0_NORMALIZATION))
|
|
||||||
currentI0=get_i0()-currentI0;
|
|
||||||
|
|
||||||
////////////////// Reput in in case of unthreaded processing
|
|
||||||
if (*threadedProcessing==0){
|
if (*threadedProcessing==0){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "start unthreaded process data " << endl;
|
cout << "start unthreaded process data " << endl;
|
||||||
@ -292,10 +163,12 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
processData(delflag);
|
processData(delflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
// wait until data processing thread has finished the data
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
while (queuesize){
|
while (queuesize){
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
@ -305,37 +178,10 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
if (*actionMask & (1 << headerAfter)) {
|
executeAction(headerAfter);
|
||||||
//Custom script after each frame. The arguments are passed as nrun=n fn=filename par=p sv0=scanvar0 sv1=scanvar1 p0=par0 p1=par1"
|
setLastIndex(*fileIndex);
|
||||||
sprintf(cmd,"%s nrun=%d fn=%s acqtime=%f gainmode=%d threshold=%d badfile=%s angfile=%s bloffset=%f fineoffset=%f fffile=%s/%s tau=%f par=%s", \
|
|
||||||
getActionScript(headerAfter).c_str(), \
|
|
||||||
nowindex, \
|
|
||||||
fn.c_str(), \
|
|
||||||
((float)timerValue[ACQUISITION_TIME])*1E-9, \
|
|
||||||
*currentSettings, \
|
|
||||||
*currentThresholdEV, \
|
|
||||||
getBadChannelCorrectionFile().c_str(), \
|
|
||||||
angularConversion::getAngularConversionFile().c_str(), \
|
|
||||||
*globalOffset, \
|
|
||||||
*fineOffset, \
|
|
||||||
getFlatFieldCorrectionDir().c_str(), \
|
|
||||||
getFlatFieldCorrectionFile().c_str(), \
|
|
||||||
getRateCorrectionTau(), \
|
|
||||||
getActionParameter(headerAfter).c_str());
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Executing header after " << cmd << endl;
|
|
||||||
#endif
|
|
||||||
system(cmd);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (*fileIndex>lastindex)
|
|
||||||
lastindex=*fileIndex;
|
|
||||||
} else {
|
} else {
|
||||||
|
setLastIndex(*fileIndex);
|
||||||
|
|
||||||
if (*fileIndex>lastindex)
|
|
||||||
lastindex=*fileIndex;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,20 +193,13 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (ip<(np-1)) {
|
} else if (ip<(np-1)) {
|
||||||
*fileIndex=startindex;
|
*fileIndex=setStartIndex();
|
||||||
}
|
}
|
||||||
} // loop on position finished
|
} // loop on position finished
|
||||||
|
|
||||||
//script after
|
//script after
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
if (*actionMask & (1 << scriptAfter)) {
|
executeAction(scriptAfter);
|
||||||
//Custom script after each frame. The arguments are passed as nrun=n fn=filename par=p sv0=scanvar0 sv1=scanvar1 p0=par0 p1=par1"
|
|
||||||
sprintf(cmd,"%s nrun=%d fn=%s par=%s sv0=%f sv1=%f p0=%s p1=%s",getActionScript(scriptAfter).c_str(),*fileIndex,createFileName().c_str(),getActionParameter(scriptAfter).c_str(),currentScanVariable[0],currentScanVariable[1],getScanParameter(0).c_str(),getScanParameter(1).c_str());
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Executing script after " << cmd << endl;
|
|
||||||
#endif
|
|
||||||
system(cmd);
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -371,14 +210,11 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (is1<(ns1-1)) {
|
} else if (is1<(ns1-1)) {
|
||||||
*fileIndex=startindex;
|
*fileIndex=setStartIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//end scan1 loop is1
|
//end scan1 loop is1
|
||||||
//currentScanVariable[MAX_SCAN_LEVELS];
|
|
||||||
|
|
||||||
|
|
||||||
if (*stoppedFlag) {
|
if (*stoppedFlag) {
|
||||||
@ -387,38 +223,28 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (is0<(ns0-1)) {
|
} else if (is0<(ns0-1)) {
|
||||||
*fileIndex=startindex;
|
*fileIndex=setStartIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end scan0 loop is0
|
} //end scan0 loop is0
|
||||||
|
|
||||||
*fileIndex=lastindex;
|
*fileIndex=setLastIndex();
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
if (*actionMask & (1 << stopScript)) {
|
executeAction(stopScript);
|
||||||
//Custom stop script. The arguments are passed as nrun=n par=p.
|
|
||||||
sprintf(cmd,"%s nrun=%d par=%s",getActionScript(stopScript).c_str(),*fileIndex,getActionParameter(stopScript).c_str());
|
|
||||||
#ifdef VERBOSE
|
|
||||||
cout << "Executing stop script " << cmd << endl;
|
|
||||||
#endif
|
|
||||||
system(cmd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// waiting for the data processing thread to finish!
|
||||||
if (*threadedProcessing) {
|
if (*threadedProcessing) {
|
||||||
//#ifdef VERBOSE
|
|
||||||
// std::cout<< " ***********************waiting for data processing thread to finish " << queuesize <<" " << thisDetector->fileIndex << std::endl ;
|
|
||||||
//#endif
|
|
||||||
//cout << "main mutex lock line 6488" << endl;
|
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
jointhread=1;
|
jointhread=1;
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
//cout << "main mutex unlock line 6488" << endl;
|
|
||||||
pthread_join(dataProcessingThread, &status);
|
pthread_join(dataProcessingThread, &status);
|
||||||
// std::cout<< " ***********************data processing finished " << queuesize <<" " << thisDetector->fileIndex << std::endl ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION)))
|
if ((*correctionMask&(1<< ANGULAR_CONVERSION)) || (*correctionMask&(1<< I0_NORMALIZATION)))
|
||||||
disconnect_channels();
|
disconnect_channels();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,13 +20,6 @@ extern "C" {
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __MAKECINT__
|
|
||||||
#pragma link off class _FTCOMSTAT-;
|
|
||||||
#pragma link off class _FTDCB-;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//#include "MySocketTCP.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -42,7 +35,6 @@ using namespace std;
|
|||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "slsDetectorBase.h"
|
#include "slsDetectorBase.h"
|
||||||
#include "energyConversion.h"
|
#include "energyConversion.h"
|
||||||
#include "postProcessing.h"
|
|
||||||
#include "slsDetectorActions.h"
|
#include "slsDetectorActions.h"
|
||||||
|
|
||||||
#define MAX_TIMERS 10
|
#define MAX_TIMERS 10
|
||||||
@ -57,7 +49,7 @@ using namespace std;
|
|||||||
|
|
||||||
(used in the PSi command line interface)
|
(used in the PSi command line interface)
|
||||||
*/
|
*/
|
||||||
class slsDetectorUtils : public slsDetectorActions, public postProcessing, public slsDetectorBase {
|
class slsDetectorUtils : public slsDetectorActions, public slsDetectorBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ string fileIO::createFileName(char *filepath, char *filename, int aMask, float
|
|||||||
/* generates file name without extension*/
|
/* generates file name without extension*/
|
||||||
|
|
||||||
string fileIO::createFileName() {
|
string fileIO::createFileName() {
|
||||||
return createFileName(filePath, \
|
currentFileName=createFileName(filePath, \
|
||||||
fileName, \
|
fileName, \
|
||||||
getActionMask(), \
|
getActionMask(), \
|
||||||
getCurrentScanVariable(0), \
|
getCurrentScanVariable(0), \
|
||||||
@ -63,6 +63,7 @@ string fileIO::createFileName() {
|
|||||||
getNumberOfPositions(), \
|
getNumberOfPositions(), \
|
||||||
*fileIndex \
|
*fileIndex \
|
||||||
);
|
);
|
||||||
|
return currentFileName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,6 +402,7 @@ class fileIO : public slsDetectorDefs {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
string currentFileName;
|
||||||
|
|
||||||
|
|
||||||
/** output directory */
|
/** output directory */
|
||||||
|
@ -112,8 +112,6 @@ int postProcessing::setBadChannelCorrection(string fname, int &nbad, int *badlis
|
|||||||
} else
|
} else
|
||||||
interrupt=1;
|
interrupt=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infile.close();
|
infile.close();
|
||||||
@ -142,7 +140,7 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
|||||||
//uses static function?!?!?!?
|
//uses static function?!?!?!?
|
||||||
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
||||||
|
|
||||||
doProcessing(fdata,delflag);
|
doProcessing(fdata,delflag, fname);
|
||||||
|
|
||||||
delete [] myData;
|
delete [] myData;
|
||||||
myData=NULL;
|
myData=NULL;
|
||||||
@ -161,17 +159,7 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void postProcessing::doProcessing(float *fdata, int delflag) {
|
void postProcessing::doProcessing(float *fdata, int delflag, string fname) {
|
||||||
|
|
||||||
|
|
||||||
float *rcdata=NULL, *rcerr=NULL;
|
|
||||||
float *ffcdata=NULL, *ffcerr=NULL;
|
|
||||||
float *ang=NULL;
|
|
||||||
// int imod;
|
|
||||||
int np;
|
|
||||||
string ext;
|
|
||||||
string fname;
|
|
||||||
detectorData *thisData;
|
|
||||||
|
|
||||||
|
|
||||||
/** write raw data file */
|
/** write raw data file */
|
||||||
@ -180,8 +168,20 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
|||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ext=".dat";
|
|
||||||
fname=createFileName();
|
|
||||||
|
|
||||||
|
float *rcdata=NULL, *rcerr=NULL;
|
||||||
|
float *ffcdata=NULL, *ffcerr=NULL;
|
||||||
|
float *ang=NULL;
|
||||||
|
// int imod;
|
||||||
|
int np;
|
||||||
|
//string fname;
|
||||||
|
detectorData *thisData;
|
||||||
|
|
||||||
|
|
||||||
|
string ext=".dat";
|
||||||
|
// fname=createFileName();
|
||||||
|
|
||||||
/** rate correction */
|
/** rate correction */
|
||||||
if (*correctionMask&(1<<RATE_CORRECTION)) {
|
if (*correctionMask&(1<<RATE_CORRECTION)) {
|
||||||
@ -215,24 +215,14 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
|||||||
rcerr=NULL;
|
rcerr=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// writes angualr converted files
|
// writes angualr converted files
|
||||||
|
|
||||||
if (*correctionMask!=0) {
|
if (*correctionMask!=0) {
|
||||||
if (*correctionMask&(1<< ANGULAR_CONVERSION))
|
if (*correctionMask&(1<< ANGULAR_CONVERSION))
|
||||||
ang=convertAngles(currentPosition);
|
ang=convertAngles(currentPosition);
|
||||||
writeDataFile (fname+string(".dat"), ffcdata, ffcerr,ang);
|
writeDataFile (fname+ext, ffcdata, ffcerr,ang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (*correctionMask&(1<< ANGULAR_CONVERSION) && (*numberOfPositions)>0) {
|
if (*correctionMask&(1<< ANGULAR_CONVERSION) && (*numberOfPositions)>0) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "**************Current position index is " << currentPositionIndex << endl;
|
cout << "**************Current position index is " << currentPositionIndex << endl;
|
||||||
@ -240,8 +230,6 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
|||||||
// if (*numberOfPositions>0) {
|
// if (*numberOfPositions>0) {
|
||||||
if (currentPositionIndex<=1) {
|
if (currentPositionIndex<=1) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "reset merging " << endl;
|
cout << "reset merging " << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -270,7 +258,6 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
|||||||
#endif
|
#endif
|
||||||
np=finalizeMerging();
|
np=finalizeMerging();
|
||||||
/** file writing */
|
/** file writing */
|
||||||
|
|
||||||
currentPositionIndex++;
|
currentPositionIndex++;
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
@ -280,7 +267,7 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "writing merged data file" << endl;
|
cout << "writing merged data file" << endl;
|
||||||
#endif
|
#endif
|
||||||
writeDataFile (fname+string(".dat"),np,getMergedCounts(), getMergedErrors(), getMergedPositions(),'f');
|
writeDataFile (fname+ext,np,getMergedCounts(), getMergedErrors(), getMergedPositions(),'f');
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << " done" << endl;
|
cout << " done" << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -290,7 +277,7 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
|||||||
if (delflag) {
|
if (delflag) {
|
||||||
deleteMerging();
|
deleteMerging();
|
||||||
} else {
|
} else {
|
||||||
thisData=new detectorData(getMergedCounts(),getMergedErrors(),getMergedPositions(),getCurrentProgress(),(fname+string(ext)).c_str(),np);
|
thisData=new detectorData(getMergedCounts(),getMergedErrors(),getMergedPositions(),getCurrentProgress(),(fname+ext).c_str(),np);
|
||||||
|
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
finalDataQueue.push(thisData);
|
finalDataQueue.push(thisData);
|
||||||
@ -321,7 +308,7 @@ void postProcessing::doProcessing(float *fdata, int delflag) {
|
|||||||
if ( ang)
|
if ( ang)
|
||||||
delete [] ang;
|
delete [] ang;
|
||||||
} else {
|
} else {
|
||||||
thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+string(ext)).c_str(),getTotalNumberOfChannels());
|
thisData=new detectorData(ffcdata,ffcerr,NULL,getCurrentProgress(),(fname+ext).c_str(),getTotalNumberOfChannels());
|
||||||
pthread_mutex_lock(&mg);
|
pthread_mutex_lock(&mg);
|
||||||
finalDataQueue.push(thisData);
|
finalDataQueue.push(thisData);
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
@ -466,6 +453,7 @@ void* postProcessing::processData(int delflag) {
|
|||||||
|
|
||||||
if (fdata)
|
if (fdata)
|
||||||
delete [] fdata;
|
delete [] fdata;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +497,6 @@ void postProcessing::resetFinalDataQueue() {
|
|||||||
delete retval;
|
delete retval;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mg);
|
pthread_mutex_unlock(&mg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ s
|
|||||||
\returns nothing
|
\returns nothing
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void doProcessing(float* myData, int delflag);
|
void doProcessing(float* myData, int delflag, string fname);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -225,7 +225,7 @@ int go_to_position_no_wait(float p) {
|
|||||||
|
|
||||||
/* reads I0 and returns the intensity */
|
/* reads I0 and returns the intensity */
|
||||||
|
|
||||||
float get_i0() {
|
float get_i0(int t) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Getting I0 readout \n");
|
printf("Getting I0 readout \n");
|
||||||
#endif
|
#endif
|
||||||
@ -240,7 +240,15 @@ float get_i0() {
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("caget: %f\n", value);
|
printf("caget: %f\n", value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
if (t==0)
|
||||||
i0=value;
|
i0=value;
|
||||||
|
else
|
||||||
|
i0=value-i0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
printf(ca_message(status));
|
printf(ca_message(status));
|
||||||
#else
|
#else
|
||||||
@ -249,6 +257,7 @@ float get_i0() {
|
|||||||
|
|
||||||
//"ca_get X04SA-ES2-SC:CH6"
|
//"ca_get X04SA-ES2-SC:CH6"
|
||||||
return i0;
|
return i0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +36,8 @@ extern "C" {
|
|||||||
int connect_channels();
|
int connect_channels();
|
||||||
int disconnect_channels();
|
int disconnect_channels();
|
||||||
|
|
||||||
float get_i0();
|
float get_i0(int t);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user