mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
frame index in file name, increments instead of file index for real time acquisitions
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@330 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -12,7 +12,7 @@ SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFuncti
|
|||||||
|
|
||||||
OBJS = $(SRC_CLNT:.cpp=.o)
|
OBJS = $(SRC_CLNT:.cpp=.o)
|
||||||
|
|
||||||
HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h multiSlsDetector/multiSlsDetectorCommand.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h usersFunctions/angleFunction.h
|
HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h multiSlsDetector/multiSlsDetectorCommand.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h usersFunctions/angleFunction.h slsReceiverInterface/receiverInterface.h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1518,6 +1518,15 @@ int multiSlsDetector::setSpeed(speedVariable index, int value){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int multiSlsDetector::getDataBytes(){
|
||||||
|
int ret=0;
|
||||||
|
for (int ip=0; ip<thisMultiDetector->numberOfDetectors; ip++) {
|
||||||
|
if (detectors[ip])
|
||||||
|
ret+=detectors[ip]->getDataBytes();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2881,11 +2890,14 @@ int multiSlsDetector::setNumberOfModules(int p, dimension d) {
|
|||||||
thisMultiDetector->numberOfChannels=0;
|
thisMultiDetector->numberOfChannels=0;
|
||||||
|
|
||||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||||
|
|
||||||
|
cout << "detector " << idet << endl;
|
||||||
if (detectors[idet]) {
|
if (detectors[idet]) {
|
||||||
if (p<0)
|
if (p<0)
|
||||||
nm=p;
|
nm=p;
|
||||||
else {
|
else {
|
||||||
mm=detectors[idet]->getMaxNumberOfModules();
|
mm=detectors[idet]->getMaxNumberOfModules();
|
||||||
|
//mm=detectors[idet]->getMaxMods();
|
||||||
if (nt>mm) {
|
if (nt>mm) {
|
||||||
nm=mm;
|
nm=mm;
|
||||||
nt-=nm;
|
nt-=nm;
|
||||||
|
@ -615,6 +615,7 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
*/
|
*/
|
||||||
int setDynamicRange(int n, int pos);
|
int setDynamicRange(int n, int pos);
|
||||||
|
|
||||||
|
int getDataBytes();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1273,6 +1273,7 @@ int slsDetector::setNumberOfModules(int n, dimension d){
|
|||||||
#endif
|
#endif
|
||||||
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
if (thisDetector->onlineFlag==ONLINE_FLAG) {
|
||||||
if (controlSocket) {
|
if (controlSocket) {
|
||||||
|
cout << "connected" << endl;
|
||||||
if (controlSocket->Connect()>=0) {
|
if (controlSocket->Connect()>=0) {
|
||||||
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
|
||||||
controlSocket->SendDataOnly(&arg,sizeof(arg));
|
controlSocket->SendDataOnly(&arg,sizeof(arg));
|
||||||
@ -1287,8 +1288,10 @@ int slsDetector::setNumberOfModules(int n, dimension d){
|
|||||||
if (ret==FORCE_UPDATE)
|
if (ret==FORCE_UPDATE)
|
||||||
updateDetector();
|
updateDetector();
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
cout << "no control socket?!??!?" << endl;
|
||||||
} else {
|
} else {
|
||||||
|
cout << "offline" << endl;
|
||||||
ret=OK;
|
ret=OK;
|
||||||
if (n==GET_FLAG)
|
if (n==GET_FLAG)
|
||||||
;
|
;
|
||||||
@ -1389,7 +1392,7 @@ int slsDetector::getMaxNumberOfModules(dimension d){
|
|||||||
std::cout<< "Max number of modules in dimension "<< d <<" is " << retval << std::endl;
|
std::cout<< "Max number of modules in dimension "<< d <<" is " << retval << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (ret==FAIL) {
|
if (ret==FAIL) {
|
||||||
std::cout<< "Get max number of modules failed " << std::endl;
|
std::cout<< "Get max number of modules failed " << retval << std::endl;
|
||||||
return retval;
|
return retval;
|
||||||
} else {
|
} else {
|
||||||
thisDetector->nModMax[d]=retval;
|
thisDetector->nModMax[d]=retval;
|
||||||
|
@ -109,7 +109,9 @@ int slsDetectorUsers::getPositions(double *pos){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int slsDetectorUsers::setDetectorSize(int x0, int y0, int nx, int ny){
|
int slsDetectorUsers::setDetectorSize(int x0, int y0, int nx, int ny){
|
||||||
return myDetector->setNumberOfModules(nx/myDetector->getChansPerMod(0))*myDetector->getChansPerMod(0);}
|
int nmod=nx/(myDetector->getChansPerMod(0));
|
||||||
|
cout << myDetector->getChansPerMod(0) << " " << nx << " " << nmod << endl;
|
||||||
|
return myDetector->setNumberOfModules(nmod)*myDetector->getChansPerMod(0);}
|
||||||
|
|
||||||
int slsDetectorUsers::getDetectorSize(int &x0, int &y0, int &nx, int &ny){
|
int slsDetectorUsers::getDetectorSize(int &x0, int &y0, int &nx, int &ny){
|
||||||
y0=0;
|
y0=0;
|
||||||
|
@ -25,12 +25,39 @@ class multiSlsDetector;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@libdoc The slsDetectorUsers class is a minimal purely virtual interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration file tha can be read/written.
|
|
||||||
|
|
||||||
|
|
||||||
This class contains the functions accessible by the users to control the slsDetectors (both multiSlsDetector and slsDetector)
|
\mainpage
|
||||||
|
<img src="psi_logo_150.gif" alt="Paul Scherrer Institut">
|
||||||
|
<CENTER><H1>API for SLS detectors data acquisition</H1></CENTER>
|
||||||
|
<HR>
|
||||||
|
Although the SLS detectors group delvelops several types of detectors (1/2D, counting/integrating etc.) it is common interest of the group to use a common platfor for data acquisition
|
||||||
|
|
||||||
|
The architecture of the acquisitions system is intended as follows:
|
||||||
|
\li A socket server running on the detector (or more than one in some special cases)
|
||||||
|
\li C++ classes common to all detectors for client-server communication. These can be supplied to users as libraries and embedded also in acquisition systems which are not developed by the SLS
|
||||||
|
\li the possibility of using a Qt-based graphical user interface (with eventually root analisys capabilities)
|
||||||
|
\li the possibility of running all commands from command line. In order to ensure a fast operation of this so called "text client" the detector parameters should not be re-initialized everytime. For this reason a shared memory block is allocated where the main detector flags and parameters are stored
|
||||||
|
\li a Root library for data postprocessing and detector calibration (energy, angle).
|
||||||
|
|
||||||
* @short This is the base class for detector functionalities of interest for the users.
|
|
||||||
|
The slsDetectorUsers class is a minimal purely virtual interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration file tha can be read/written.
|
||||||
|
|
||||||
|
|
||||||
|
\authors <a href="mailto:anna.bergamaschi@psi.ch">Anna Bergamaschi</a>, <a href="mailto:dhanya.maliakal@psi.ch">Dhanya Maliakal</a>
|
||||||
|
@version 0.2
|
||||||
|
<H2>Currently supported detectors</H2>
|
||||||
|
\li MYTHEN
|
||||||
|
\li GOTTHARD controls
|
||||||
|
<H3>Coming soon</H3>
|
||||||
|
\li GOTTHARD data receiver
|
||||||
|
\li EIGER
|
||||||
|
|
||||||
|
@libdoc The slsDetectorUsers class is a minimal purely virtual interface class which should be instantiated by the users in their acquisition software (EPICS, spec etc.). More advanced configuration functions are not implemented and can be written in a configuration or parameters file that can be read/written.
|
||||||
|
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
@short This is the base class for detector functionalities of interest for the users. Can be emebedded in the users custom interface e.g. EPICS, Lima etc.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
if (nm<1)
|
if (nm<1)
|
||||||
nm=1;
|
nm=1;
|
||||||
|
|
||||||
|
|
||||||
int np=getNumberOfPositions();
|
int np=getNumberOfPositions();
|
||||||
if (np<1)
|
if (np<1)
|
||||||
np=1;
|
np=1;
|
||||||
@ -129,9 +130,9 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
|
|
||||||
//loop measurements
|
//loop measurements
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
// pthread_mutex_lock(&mp);
|
||||||
setStartIndex(*fileIndex);
|
// setStartIndex(*fileIndex);
|
||||||
pthread_mutex_unlock(&mp);
|
// pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
//cout << "action at start" << endl;
|
//cout << "action at start" << endl;
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
@ -216,11 +217,19 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
get_i0(0, IOarg);
|
get_i0(0, IOarg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((timerValue[FRAME_NUMBER]*timerValue[CYCLES_NUMBER])>1) {
|
||||||
|
setFrameIndex(0);
|
||||||
|
} else {
|
||||||
|
setFrameIndex(-1);
|
||||||
|
}
|
||||||
|
|
||||||
startAndReadAll();
|
startAndReadAll();
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "returned! " << endl;
|
cout << "returned! " << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (*correctionMask&(1<< I0_NORMALIZATION)) {
|
if (*correctionMask&(1<< I0_NORMALIZATION)) {
|
||||||
if (get_i0)
|
if (get_i0)
|
||||||
currentI0=get_i0(1,IOarg); // this is the correct i0!!!!!
|
currentI0=get_i0(1,IOarg); // this is the correct i0!!!!!
|
||||||
@ -259,13 +268,14 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
usleep(100000);
|
usleep(100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeDataFile();
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
executeAction(headerAfter);
|
executeAction(headerAfter);
|
||||||
setLastIndex(*fileIndex);
|
// setLastIndex(*fileIndex);
|
||||||
} else {
|
} else {
|
||||||
setLastIndex(*fileIndex);
|
// setLastIndex(*fileIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
@ -277,9 +287,9 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (ip<(np-1)) {
|
} else if (ip<(np-1)) {
|
||||||
pthread_mutex_lock(&mp);
|
// pthread_mutex_lock(&mp);
|
||||||
*fileIndex=setStartIndex();
|
// *fileIndex=setStartIndex();
|
||||||
pthread_mutex_unlock(&mp);
|
// pthread_mutex_unlock(&mp);
|
||||||
}
|
}
|
||||||
} // loop on position finished
|
} // loop on position finished
|
||||||
|
|
||||||
@ -296,9 +306,9 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (is1<(ns1-1)) {
|
} else if (is1<(ns1-1)) {
|
||||||
pthread_mutex_lock(&mp);
|
// pthread_mutex_lock(&mp);
|
||||||
*fileIndex=setStartIndex();
|
// *fileIndex=setStartIndex();
|
||||||
pthread_mutex_unlock(&mp);
|
// pthread_mutex_unlock(&mp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,22 +321,32 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (is0<(ns0-1)) {
|
} else if (is0<(ns0-1)) {
|
||||||
pthread_mutex_lock(&mp);
|
// pthread_mutex_lock(&mp);
|
||||||
*fileIndex=setStartIndex();
|
// *fileIndex=setStartIndex();
|
||||||
pthread_mutex_unlock(&mp);
|
// pthread_mutex_unlock(&mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end scan0 loop is0
|
} //end scan0 loop is0
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
// pthread_mutex_lock(&mp);
|
||||||
*fileIndex=setLastIndex();
|
// *fileIndex=setLastIndex();
|
||||||
pthread_mutex_unlock(&mp);
|
// pthread_mutex_unlock(&mp);
|
||||||
|
|
||||||
if (*stoppedFlag==0) {
|
if (*stoppedFlag==0) {
|
||||||
executeAction(stopScript);
|
executeAction(stopScript);
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// loop measurements
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef VERBOSE
|
||||||
|
cout << "findex incremented " << endl;
|
||||||
|
#endif
|
||||||
|
if(*correctionMask&(1<<WRITE_FILE))
|
||||||
|
IncrementFileIndex();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (measurement_finished)
|
if (measurement_finished)
|
||||||
@ -337,6 +357,7 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// loop measurements
|
||||||
}
|
}
|
||||||
|
|
||||||
// waiting for the data processing thread to finish!
|
// waiting for the data processing thread to finish!
|
||||||
@ -358,7 +379,6 @@ void slsDetectorUtils::acquire(int delflag){
|
|||||||
delete eclog;
|
delete eclog;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (acquisition_finished)
|
if (acquisition_finished)
|
||||||
acquisition_finished(getCurrentProgress(),getDetectorStatus(),acqFinished_p);
|
acquisition_finished(getCurrentProgress(),getDetectorStatus(),acqFinished_p);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
class detectorData {
|
class detectorData {
|
||||||
public:
|
public:
|
||||||
/** The constructor
|
/** @short The constructor
|
||||||
\param val pointer to the data
|
\param val pointer to the data
|
||||||
\param err pointer to errors
|
\param err pointer to errors
|
||||||
\param ang pointer to the angles
|
\param ang pointer to the angles
|
||||||
@ -21,18 +21,18 @@ class detectorData {
|
|||||||
*/
|
*/
|
||||||
detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny){strcpy(fileName,fname);};
|
detectorData(double *val=NULL, double *err=NULL, double *ang=NULL, double p_ind=-1, const char *fname="", int np=-1, int ny=1) : values(val), errors(err), angles(ang), progressIndex(p_ind), npoints(np), npy(ny){strcpy(fileName,fname);};
|
||||||
/**
|
/**
|
||||||
the destructor
|
@short The destructor
|
||||||
deletes also the arrays pointing to data/errors/angles if not NULL
|
deletes also the arrays pointing to data/errors/angles if not NULL
|
||||||
*/
|
*/
|
||||||
~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles;};
|
~detectorData() {if (values) delete [] values; if (errors) delete [] errors; if (angles) delete [] angles;};
|
||||||
//private:
|
//private:
|
||||||
double *values; /**< pointer to the data */
|
double *values; /**< @short pointer to the data */
|
||||||
double *errors; /**< pointer to the errors */
|
double *errors; /**< @short pointer to the errors */
|
||||||
double *angles;/**< pointer to the angles */
|
double *angles;/**< @short pointer to the angles (NULL if no angular conversion) */
|
||||||
double progressIndex;/**< file index */
|
double progressIndex;/**< @short file index */
|
||||||
char fileName[1000];/**< file name */
|
char fileName[1000];/**< @short file name */
|
||||||
int npoints;/**< number of points */
|
int npoints;/**< @short number of points */
|
||||||
int npy;/**< dimensions in y coordinate*/
|
int npy;/**< @short dimensions in y coordinate*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,6 +69,9 @@ int fileIO::writeDataFile(string fname, int *data){
|
|||||||
return fileIOStatic::writeDataFile(fname, getTotalNumberOfChannels(), data);
|
return fileIOStatic::writeDataFile(fname, getTotalNumberOfChannels(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int fileIO::writeDataFile(ofstream &outfile, int *data, int offset){
|
int fileIO::writeDataFile(ofstream &outfile, int *data, int offset){
|
||||||
|
|
||||||
return fileIOStatic::writeDataFile(outfile, getTotalNumberOfChannels(), data, offset);
|
return fileIOStatic::writeDataFile(outfile, getTotalNumberOfChannels(), data, offset);
|
||||||
@ -76,6 +79,41 @@ int fileIO::writeDataFile(ofstream &outfile, int *data, int offset){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int fileIO::writeDataFile(void *data, int iframe) {
|
||||||
|
if (iframe>=0)
|
||||||
|
frameIndex=iframe;
|
||||||
|
|
||||||
|
if (*framesPerFile<2)
|
||||||
|
frameIndex=-1;
|
||||||
|
|
||||||
|
if ((frameIndex%(*framesPerFile))==0 || (frameIndex<0)) {
|
||||||
|
createFileName();
|
||||||
|
filefd = fopen(currentFileName.c_str(), "w");
|
||||||
|
}
|
||||||
|
if (filefd){
|
||||||
|
if (iframe%(*framesPerFile)) {
|
||||||
|
fileIOStatic::writeBinaryDataFile(filefd,getDataBytes() , data);
|
||||||
|
frameIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((frameIndex%(*framesPerFile)==0) || (frameIndex<0)) {
|
||||||
|
if (filefd)
|
||||||
|
fclose(filefd);
|
||||||
|
filefd=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int fileIO::closeDataFile() {
|
||||||
|
if (filefd)
|
||||||
|
fclose(filefd);
|
||||||
|
filefd=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int fileIO::writeDataFile(string fname, short int *data){
|
int fileIO::writeDataFile(string fname, short int *data){
|
||||||
@ -83,6 +121,14 @@ int fileIO::writeDataFile(string fname, short int *data){
|
|||||||
return fileIOStatic::writeDataFile(fname, getTotalNumberOfChannels(), data);
|
return fileIOStatic::writeDataFile(fname, getTotalNumberOfChannels(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int fileIO::writeDataFile(ofstream &outfile, short int *data, int offset){
|
int fileIO::writeDataFile(ofstream &outfile, short int *data, int offset){
|
||||||
|
|
||||||
return fileIOStatic::writeDataFile(outfile, getTotalNumberOfChannels(), data, offset);
|
return fileIOStatic::writeDataFile(outfile, getTotalNumberOfChannels(), data, offset);
|
||||||
@ -91,6 +137,12 @@ int fileIO::writeDataFile(ofstream &outfile, short int *data, int offset){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int fileIO::readDataFile(string fname, double *data, double *err, double *ang, char dataformat) {
|
int fileIO::readDataFile(string fname, double *data, double *err, double *ang, char dataformat) {
|
||||||
return fileIOStatic::readDataFile(getTotalNumberOfChannels(), fname, data, err, ang, dataformat);
|
return fileIOStatic::readDataFile(getTotalNumberOfChannels(), fname, data, err, ang, dataformat);
|
||||||
|
|
||||||
|
@ -22,8 +22,16 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/* enum rawFileFormat { */
|
||||||
|
/* ASCII, */
|
||||||
|
/* BINARY */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
|
||||||
/** default constructor */
|
/** default constructor */
|
||||||
fileIO(): fileIOStatic(){frameIndex=-1;detIndex=-1;};
|
fileIO(): fileIOStatic(){frameIndex=-1;detIndex=-1; framesPerFile=&nframes; nframes=1; };
|
||||||
|
|
||||||
/** virtual destructor */
|
/** virtual destructor */
|
||||||
virtual ~fileIO(){};
|
virtual ~fileIO(){};
|
||||||
|
|
||||||
@ -62,6 +70,13 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
*/
|
*/
|
||||||
virtual int setFrameIndex(int i) {frameIndex=i; return frameIndex;};
|
virtual int setFrameIndex(int i) {frameIndex=i; return frameIndex;};
|
||||||
|
|
||||||
|
/**
|
||||||
|
sets the default output file index
|
||||||
|
\param i frame index to be set
|
||||||
|
\returns actual frame index
|
||||||
|
*/
|
||||||
|
virtual int setFramesPerFile(int i) {if (i>0) *framesPerFile=i; return *framesPerFile;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
sets the default output file index
|
sets the default output file index
|
||||||
\param i detector index to be set
|
\param i detector index to be set
|
||||||
@ -74,7 +89,6 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
virtual string getFilePath() {return string(filePath);};
|
virtual string getFilePath() {return string(filePath);};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\returns the output files root name
|
\returns the output files root name
|
||||||
*/
|
*/
|
||||||
@ -102,17 +116,14 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
writes a data file
|
writes a data file
|
||||||
\param fname of the file to be written
|
\param fname of the file to be written
|
||||||
\param data array of data values
|
\param data array of data values
|
||||||
\param err array of arrors on the data. If NULL no errors will be written
|
\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 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' double (default)
|
\param dataformat format of the data: can be 'i' integer or 'f' double (default)
|
||||||
\param nch number of channels to be written to file. if -1 defaults to the number of installed channels of the detector
|
\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
|
\returns OK or FAIL if it could not write the file or data=NULL
|
||||||
|
|
||||||
*/
|
*/
|
||||||
virtual int writeDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1);
|
virtual int writeDataFile(string fname, double *data, double *err=NULL, double *ang=NULL, char dataformat='f', int nch=-1);
|
||||||
|
|
||||||
@ -120,7 +131,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
/**
|
/**
|
||||||
|
|
||||||
writes a data file
|
writes a data file
|
||||||
\paramoutfile output file stream
|
\param outfile output file stream
|
||||||
\param data array of data values
|
\param data array of data values
|
||||||
\param err array of arrors on the data. If NULL no errors will be written
|
\param err array of arrors on the data. If NULL no errors will be written
|
||||||
|
|
||||||
@ -142,6 +153,10 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
*/
|
*/
|
||||||
virtual int writeDataFile(string fname, int *data);
|
virtual int writeDataFile(string fname, int *data);
|
||||||
|
|
||||||
|
|
||||||
|
virtual int writeDataFile(void *data, int iframe=-1);
|
||||||
|
|
||||||
|
int closeDataFile();
|
||||||
/**
|
/**
|
||||||
writes a data file
|
writes a data file
|
||||||
\param outfile output file stream
|
\param outfile output file stream
|
||||||
@ -161,6 +176,12 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
*/
|
*/
|
||||||
virtual int writeDataFile(string fname, short int *data);
|
virtual int writeDataFile(string fname, short int *data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
writes a data file of short ints
|
writes a data file of short ints
|
||||||
\param outfile output file stream
|
\param outfile output file stream
|
||||||
@ -200,8 +221,10 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
\param fname of the file to be read
|
\param fname of the file to be read
|
||||||
\param data array of data values
|
\param data array of data values
|
||||||
\returns OK or FAIL if it could not read the file or data=NULL
|
\returns OK or FAIL if it could not read the file or data=NULL
|
||||||
*/
|
yes */
|
||||||
virtual int readDataFile(string fname, int *data); /**
|
virtual int readDataFile(string fname, int *data);
|
||||||
|
|
||||||
|
/**
|
||||||
reads a raw data file
|
reads a raw data file
|
||||||
\param infile input file stream
|
\param infile input file stream
|
||||||
\param data array of data values
|
\param data array of data values
|
||||||
@ -227,6 +250,7 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
*/
|
*/
|
||||||
int readDataFile(ifstream &infile, short int *data, int offset=0);
|
int readDataFile(ifstream &infile, short int *data, int offset=0);
|
||||||
|
|
||||||
|
virtual int getDataBytes ( )=0;
|
||||||
friend class slsDetector;
|
friend class slsDetector;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -238,28 +262,40 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
|
|
||||||
void incrementDetectorIndex() { (detIndex)++; };
|
void incrementDetectorIndex() { (detIndex)++; };
|
||||||
|
|
||||||
string getCurrentFileName(){return currentFileName;};
|
string getCurrentFileName(){return currentFileName;};
|
||||||
|
|
||||||
string getCurrentReceiverFilePrefix(){return currentReceiverFilePrefix;};
|
string getCurrentReceiverFilePrefix(){return currentReceiverFilePrefix;};
|
||||||
|
|
||||||
|
|
||||||
|
string currentFileName;
|
||||||
|
|
||||||
|
string currentReceiverFilePrefix;
|
||||||
string currentFileName;
|
|
||||||
|
|
||||||
string currentReceiverFilePrefix;
|
|
||||||
|
|
||||||
|
|
||||||
/** output directory */
|
/** output directory */
|
||||||
char *filePath;
|
char *filePath;
|
||||||
/** file root name */
|
/** file root name */
|
||||||
char *fileName;
|
char *fileName;
|
||||||
/** file index */
|
/** file index */
|
||||||
int *fileIndex;
|
int *fileIndex;
|
||||||
/** frame index */
|
/** frame index */
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
/** detector id */
|
/** detector id */
|
||||||
int detIndex;
|
int detIndex;
|
||||||
|
/** frames per file */
|
||||||
|
int *framesPerFile;
|
||||||
|
|
||||||
|
// int *fileFormat;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
FILE *filefd;
|
||||||
|
ofstream fstream;
|
||||||
|
|
||||||
|
int nframes;
|
||||||
|
// int fformat;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,11 +59,11 @@ class fileIOStatic {
|
|||||||
static string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex, int frameindex=-1, int detindex=-1){ \
|
static string createFileName(char *filepath, char *filename, int aMask, double sv0, int prec0, double sv1, int prec1, int pindex, int npos, int findex, int frameindex=-1, int detindex=-1){ \
|
||||||
ostringstream osfn; \
|
ostringstream osfn; \
|
||||||
osfn << filepath << "/" << filename; \
|
osfn << filepath << "/" << filename; \
|
||||||
if(detindex!=-1) osfn << "_d"<< detindex; \
|
if(detindex>=0) osfn << "_d"<< detindex; \
|
||||||
if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << fixed << setprecision(prec0) << sv0; \
|
if ( aMask& (1 << (slsDetectorDefs::MAX_ACTIONS))) osfn << "_S" << fixed << setprecision(prec0) << sv0; \
|
||||||
if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << fixed << setprecision(prec1) << sv1; \
|
if (aMask & (1 << (slsDetectorDefs::MAX_ACTIONS+1))) osfn << "_s" << fixed << setprecision(prec1) << sv1; \
|
||||||
if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \
|
if (pindex>0 && pindex<=npos) osfn << "_p" << pindex; \
|
||||||
if(frameindex!=-1) osfn << "_f" << frameindex; \
|
if(frameindex>=0) osfn << "_f" << frameindex; \
|
||||||
osfn << "_" << findex; \
|
osfn << "_" << findex; \
|
||||||
return osfn.str(); \
|
return osfn.str(); \
|
||||||
};
|
};
|
||||||
@ -278,6 +278,9 @@ class fileIOStatic {
|
|||||||
} \
|
} \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
writes a data file
|
writes a data file
|
||||||
\param outfile output file stream
|
\param outfile output file stream
|
||||||
@ -340,7 +343,30 @@ class fileIOStatic {
|
|||||||
} \
|
} \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
writes a raw data file in binary format
|
||||||
|
\param fname of the file to be written
|
||||||
|
\param number of bytes to write
|
||||||
|
\param data array of data values
|
||||||
|
\returns OK or FAIL if it could not write the file or data=NULL
|
||||||
|
*/
|
||||||
|
static int writeBinaryDataFile(string fname, size_t nbytes, void *data){ \
|
||||||
|
FILE *sfilefd; \
|
||||||
|
if (data==NULL) return slsDetectorDefs::FAIL; \
|
||||||
|
sfilefd = fopen(fname.c_str(), "w"); \
|
||||||
|
if (sfilefd) { \
|
||||||
|
writeBinaryDataFile(sfilefd, nbytes, data); \
|
||||||
|
fclose(sfilefd); \
|
||||||
|
return slsDetectorDefs::OK; \
|
||||||
|
} \
|
||||||
|
return slsDetectorDefs::FAIL; \
|
||||||
|
};
|
||||||
|
|
||||||
|
static int writeBinaryDataFile(FILE *sfilefd, size_t nbytes, void *data){ \
|
||||||
|
fwrite(data, 1, nbytes, sfilefd); \
|
||||||
|
return slsDetectorDefs::OK; \
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
writes a raw data file
|
writes a raw data file
|
||||||
\param outfile output file stream
|
\param outfile output file stream
|
||||||
@ -396,8 +422,6 @@ class fileIOStatic {
|
|||||||
return slsDetectorDefs::OK; \
|
return slsDetectorDefs::OK; \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
reads a data file
|
reads a data file
|
||||||
\param nch number of channels
|
\param nch number of channels
|
||||||
|
@ -62,65 +62,71 @@ void postProcessing::processFrame(int *myData, int delflag) {
|
|||||||
|
|
||||||
/** decode data */
|
/** decode data */
|
||||||
|
|
||||||
fdata=decodeData(myData, fdata);
|
if (getDetectorsType()==MYTHEN) {
|
||||||
|
fdata=decodeData(myData, fdata);
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "decode"<< endl;
|
cout << "decode"<< endl;
|
||||||
#endif
|
#endif
|
||||||
|
} else
|
||||||
if (rawDataReady) {
|
fdata=NULL;
|
||||||
//#ifdef VERBOSE
|
|
||||||
cout << "raw data ready..." << endl;
|
|
||||||
//#endif
|
|
||||||
rawDataReady(fdata,numberOfChannels, pRawDataArg);
|
|
||||||
//#ifdef VERBOSE
|
|
||||||
cout << "done" << endl;
|
|
||||||
cout << "NO FILE WRITING AND/OR DATA PROCESSING DONE BY SLS DETECTOR SOFTWARE!!!" << endl;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
} else {
|
if (rawDataReady) {
|
||||||
|
//#ifdef VERBOSE
|
||||||
|
cout << "raw data ready..." << endl;
|
||||||
|
//#endif
|
||||||
|
rawDataReady(fdata,numberOfChannels, pRawDataArg);
|
||||||
|
//#ifdef VERBOSE
|
||||||
|
cout << "done" << endl;
|
||||||
|
cout << "NO FILE WRITING AND/OR DATA PROCESSING DONE BY SLS DETECTOR SOFTWARE!!!" << endl;
|
||||||
|
//#endif
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
fname=createFileName();
|
fname=createFileName();
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "fname is " << fname << endl;
|
cout << "fname is " << fname << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Checking for write flag
|
//Checking for write flag
|
||||||
if((*correctionMask)&(1<<WRITE_FILE)) {
|
if((*correctionMask)&(1<<WRITE_FILE)) {
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "writing raw data " << endl;
|
cout << "writing raw data " << endl;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
//uses static function?!?!?!?
|
if (fdata) {
|
||||||
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
//uses static function?!?!?!?
|
||||||
|
writeDataFile (fname+string(".raw"),fdata, NULL, NULL, 'i');
|
||||||
#ifdef VERBOSE
|
} else {
|
||||||
cout << "done " << endl;
|
writeDataFile ((void*)myData);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if ((*correctionMask) & ~(1<<WRITE_FILE)) {
|
|
||||||
doProcessing(fdata,delflag, fname);
|
|
||||||
} else
|
|
||||||
if (dataReady) {
|
|
||||||
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels());
|
|
||||||
dataReady(thisData, pCallbackArg);
|
|
||||||
delete thisData;
|
|
||||||
fdata=NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "findex incremented " << endl;
|
cout << "done " << endl;
|
||||||
#endif
|
#endif
|
||||||
if(*correctionMask&(1<<WRITE_FILE))
|
|
||||||
IncrementFileIndex();
|
}
|
||||||
}
|
if ((*correctionMask) & ~(1<<WRITE_FILE)) {
|
||||||
|
doProcessing(fdata,delflag, fname);
|
||||||
|
} else
|
||||||
|
if (dataReady) {
|
||||||
|
thisData=new detectorData(fdata,NULL,NULL,getCurrentProgress(),(fname+string(".raw")).c_str(),getTotalNumberOfChannels());
|
||||||
|
dataReady(thisData, pCallbackArg);
|
||||||
|
delete thisData;
|
||||||
|
fdata=NULL;
|
||||||
|
}
|
||||||
|
// #ifdef VERBOSE
|
||||||
|
// cout << "findex incremented " << endl;
|
||||||
|
// #endif
|
||||||
|
// if(*correctionMask&(1<<WRITE_FILE))
|
||||||
|
// IncrementFileIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getFrameIndex()>=0)
|
||||||
|
incrementFrameIndex();
|
||||||
|
|
||||||
|
|
||||||
delete [] myData;
|
delete [] myData;
|
||||||
if (fdata)
|
if (fdata)
|
||||||
@ -179,7 +185,7 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
|
|||||||
cout << "exptime is "<< t << endl;
|
cout << "exptime is "<< t << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (GetCurrentPositionIndex()<=1) {
|
if (GetCurrentPositionIndex()<=1 || npos<2) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "init dataset" << endl;
|
cout << "init dataset" << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -199,25 +205,26 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
|
|||||||
cout << "add frame" << endl;
|
cout << "add frame" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
addFrame(lfdata,currentPosition, currentI0, t, fname, 0);
|
addFrame(lfdata,currentPosition, currentI0, t, fname, 0);
|
||||||
|
|
||||||
if ((GetCurrentPositionIndex()>=npos && positionFinished() && dataQueueSize()) || npos==0) {
|
if ((GetCurrentPositionIndex()>=npos && positionFinished() && dataQueueSize()) || npos<2) {
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "finalize dataset" << endl;
|
cout << "finalize dataset" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
finalizeDataset(ang, val, err, np);
|
finalizeDataset(ang, val, err, np);
|
||||||
|
//if (npos<2) {
|
||||||
IncrementPositionIndex();
|
IncrementPositionIndex();
|
||||||
|
|
||||||
pthread_mutex_lock(&mp);
|
pthread_mutex_lock(&mp);
|
||||||
fname=createFileName();
|
fname=createFileName();
|
||||||
pthread_mutex_unlock(&mp);
|
pthread_mutex_unlock(&mp);
|
||||||
|
//}
|
||||||
|
|
||||||
if((*correctionMask)&(1<<WRITE_FILE)) {
|
if((*correctionMask)&(1<<WRITE_FILE)) {
|
||||||
writeDataFile (fname+ext,np,val, err,ang,'f');
|
writeDataFile (fname+ext,np,val, err,ang,'f');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (dataReady) {
|
if (dataReady) {
|
||||||
@ -236,10 +243,6 @@ void postProcessing::doProcessing(double *lfdata, int delflag, string fname) {
|
|||||||
if (err)
|
if (err)
|
||||||
delete [] err;
|
delete [] err;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,8 +257,7 @@ s
|
|||||||
void addFrame(double *data, double pos, double i0, double t, string fname, double var);
|
void addFrame(double *data, double pos, double i0, double t, string fname, double var);
|
||||||
void finalizeDataset(double *a, double *v, double *e, int &np);
|
void finalizeDataset(double *a, double *v, double *e, int &np);
|
||||||
|
|
||||||
|
virtual detectorType getDetectorsType(int pos=-1)=0;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -15,17 +15,21 @@ boot: $(OBJS)
|
|||||||
#doc: $(SRC_CLNT)
|
#doc: $(SRC_CLNT)
|
||||||
# doxygen doxy.config
|
# doxygen doxy.config
|
||||||
|
|
||||||
|
#%.o : %.c %.h
|
||||||
|
# $(CXX) -Wall -o $@ -c $< $(INCLUDES) $(CFLAGS) $(FLAGS) $(LDLIBS) -fPIC
|
||||||
|
|
||||||
$(PROGS): $(OBJS)
|
|
||||||
|
|
||||||
|
$(PROGS):
|
||||||
echo $(OBJS)
|
echo $(OBJS)
|
||||||
mkdir -p $(INSTDIR)
|
mkdir -p $(INSTDIR)
|
||||||
$(CC) $(LDFLAGS) $^ $(LDLIBS) $(CFLAGS) -o $@
|
$(CC) $(SRC_CLNT) $(LDFLAGS) $(LDLIBS) $(CFLAGS) -o $@
|
||||||
mv $(PROGS) $(INSTDIR)
|
mv $(PROGS) $(INSTDIR)
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(PROGS) *.o $(INSTDIR)/*
|
rm -rf $(PROGS) *.o $(INSTDIR)/*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user