mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
moving towards c++ api
This commit is contained in:
parent
a67f9d50de
commit
e7621a6cd0
@ -76,6 +76,7 @@ using namespace std;
|
|||||||
#define RECEIVER_READ_TIMER 0x0000000008000000ULL
|
#define RECEIVER_READ_TIMER 0x0000000008000000ULL
|
||||||
#define RECEIVER_ACQ_TIME_NOT_SET 0x0000000010000000ULL
|
#define RECEIVER_ACQ_TIME_NOT_SET 0x0000000010000000ULL
|
||||||
#define RECEIVER_FLIPPED_DATA_NOT_SET 0x0000000020000000ULL
|
#define RECEIVER_FLIPPED_DATA_NOT_SET 0x0000000020000000ULL
|
||||||
|
#define RECEIVER_FILE_FORMAT 0x0000000040000000ULL
|
||||||
|
|
||||||
// 0x00000000FFFFFFFFULL
|
// 0x00000000FFFFFFFFULL
|
||||||
/** @short class returning all error messages for error mask */
|
/** @short class returning all error messages for error mask */
|
||||||
@ -236,6 +237,10 @@ public:
|
|||||||
if(slsErrorMask&RECEIVER_FLIPPED_DATA_NOT_SET)
|
if(slsErrorMask&RECEIVER_FLIPPED_DATA_NOT_SET)
|
||||||
retval.append("Could not set receiver flipped data/bottom\n");
|
retval.append("Could not set receiver flipped data/bottom\n");
|
||||||
|
|
||||||
|
|
||||||
|
if(slsErrorMask&RECEIVER_FILE_FORMAT)
|
||||||
|
retval.append("Could not set receiver file format\n");
|
||||||
|
|
||||||
//------------------------------------------------------ length of message
|
//------------------------------------------------------ length of message
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,6 +140,10 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
|||||||
thisMultiDetector->fileIndex=0;
|
thisMultiDetector->fileIndex=0;
|
||||||
/** set frames per file to default to 1*/
|
/** set frames per file to default to 1*/
|
||||||
thisMultiDetector->framesPerFile=1;
|
thisMultiDetector->framesPerFile=1;
|
||||||
|
/** set fileIndex to default to 0*/
|
||||||
|
thisMultiDetector->fileIndex=0;
|
||||||
|
/** set fileFormat to default to ascii*/
|
||||||
|
thisMultiDetector->fileFormatType=ASCII;
|
||||||
|
|
||||||
/** set progress Index to default to 0*/
|
/** set progress Index to default to 0*/
|
||||||
thisMultiDetector->progressIndex=0;
|
thisMultiDetector->progressIndex=0;
|
||||||
@ -245,6 +249,7 @@ multiSlsDetector::multiSlsDetector(int id) : slsDetectorUtils(), shmId(-1)
|
|||||||
fileName=thisMultiDetector->fileName;
|
fileName=thisMultiDetector->fileName;
|
||||||
fileIndex=&thisMultiDetector->fileIndex;
|
fileIndex=&thisMultiDetector->fileIndex;
|
||||||
framesPerFile=&thisMultiDetector->framesPerFile;
|
framesPerFile=&thisMultiDetector->framesPerFile;
|
||||||
|
fileFormatType=&thisMultiDetector->fileFormatType;
|
||||||
|
|
||||||
|
|
||||||
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||||
@ -4824,6 +4829,25 @@ string multiSlsDetector::setFileName(string s) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
slsReceiverDefs::fileFormat multiSlsDetector::setFileFormat(fileFormat f) {
|
||||||
|
int ret=-100, ret1;
|
||||||
|
|
||||||
|
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||||
|
if (detectors[idet]) {
|
||||||
|
ret1=(int)detectors[idet]->setFileFormat(f);
|
||||||
|
if(detectors[idet]->getErrorMask())
|
||||||
|
setErrorMask(getErrorMask()|(1<<idet));
|
||||||
|
if (ret==-100)
|
||||||
|
ret=ret1;
|
||||||
|
else if (ret!=ret1)
|
||||||
|
ret=-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (fileFormat)ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int multiSlsDetector::setFileIndex(int i) {
|
int multiSlsDetector::setFileIndex(int i) {
|
||||||
int ret=-100, ret1;
|
int ret=-100, ret1;
|
||||||
|
|
||||||
|
@ -121,6 +121,8 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
char filePath[MAX_STR_LENGTH];
|
char filePath[MAX_STR_LENGTH];
|
||||||
/** max frames per file */
|
/** max frames per file */
|
||||||
int framesPerFile;
|
int framesPerFile;
|
||||||
|
/** file format*/
|
||||||
|
fileFormat fileFormatType;
|
||||||
|
|
||||||
/** corrections to be applied to the data \see ::correctionFlags */
|
/** corrections to be applied to the data \see ::correctionFlags */
|
||||||
int correctionMask;
|
int correctionMask;
|
||||||
@ -1149,6 +1151,13 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
*/
|
*/
|
||||||
string setFileName(string s="");
|
string setFileName(string s="");
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets up the file format
|
||||||
|
@param f file format
|
||||||
|
\returns file format
|
||||||
|
*/
|
||||||
|
fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets up the file index
|
Sets up the file index
|
||||||
@param i file index
|
@param i file index
|
||||||
@ -1166,6 +1175,11 @@ class multiSlsDetector : public slsDetectorUtils {
|
|||||||
*/
|
*/
|
||||||
string getFileName(){return setFileName();};
|
string getFileName(){return setFileName();};
|
||||||
|
|
||||||
|
/**
|
||||||
|
\returns file name
|
||||||
|
*/
|
||||||
|
fileFormat getFileFormat(){return setFileFormat();};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\returns file index
|
\returns file index
|
||||||
*/
|
*/
|
||||||
|
@ -863,15 +863,29 @@ int slsDetector::initializeDetectorSize(detectorType type) {
|
|||||||
fileName=parentDet->fileName;
|
fileName=parentDet->fileName;
|
||||||
fileIndex=parentDet->fileIndex;
|
fileIndex=parentDet->fileIndex;
|
||||||
framesPerFile=parentDet->framesPerFile;
|
framesPerFile=parentDet->framesPerFile;
|
||||||
if((thisDetector->myDetectorType==GOTTHARD)||(thisDetector->myDetectorType==PROPIX))
|
fileFormatType=parentDet->fileFormatType;
|
||||||
|
if((thisDetector->myDetectorType==GOTTHARD)||(thisDetector->myDetectorType==PROPIX)){
|
||||||
setFramesPerFile(MAX_FRAMES_PER_FILE);
|
setFramesPerFile(MAX_FRAMES_PER_FILE);
|
||||||
if (thisDetector->myDetectorType==MOENCH)
|
pthread_mutex_unlock(&ms);
|
||||||
|
setFileFormat(BINARY);
|
||||||
|
}else if (thisDetector->myDetectorType==EIGER){
|
||||||
|
setFramesPerFile(EIGER_MAX_FRAMES_PER_FILE);
|
||||||
|
pthread_mutex_unlock(&ms);
|
||||||
|
setFileFormat(BINARY);
|
||||||
|
}else if (thisDetector->myDetectorType==MOENCH){
|
||||||
setFramesPerFile(MOENCH_MAX_FRAMES_PER_FILE);
|
setFramesPerFile(MOENCH_MAX_FRAMES_PER_FILE);
|
||||||
if (thisDetector->myDetectorType==JUNGFRAU)
|
pthread_mutex_unlock(&ms);
|
||||||
|
setFileFormat(BINARY);
|
||||||
|
}else if (thisDetector->myDetectorType==JUNGFRAU){
|
||||||
setFramesPerFile(JFRAU_MAX_FRAMES_PER_FILE);
|
setFramesPerFile(JFRAU_MAX_FRAMES_PER_FILE);
|
||||||
if (thisDetector->myDetectorType==JUNGFRAUCTB)
|
pthread_mutex_unlock(&ms);
|
||||||
|
setFileFormat(BINARY);
|
||||||
|
}else if (thisDetector->myDetectorType==JUNGFRAUCTB){
|
||||||
setFramesPerFile(JFCTB_MAX_FRAMES_PER_FILE);
|
setFramesPerFile(JFCTB_MAX_FRAMES_PER_FILE);
|
||||||
pthread_mutex_unlock(&ms);
|
pthread_mutex_unlock(&ms);
|
||||||
|
setFileFormat(BINARY);
|
||||||
|
}else
|
||||||
|
pthread_mutex_unlock(&ms);
|
||||||
thisReceiver = new receiverInterface(dataSocket);
|
thisReceiver = new receiverInterface(dataSocket);
|
||||||
|
|
||||||
// setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips);
|
// setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips);
|
||||||
@ -5640,6 +5654,7 @@ char* slsDetector::setReceiver(string receiverIP){
|
|||||||
setFilePath(fileIO::getFilePath());
|
setFilePath(fileIO::getFilePath());
|
||||||
setFileName(fileIO::getFileName());
|
setFileName(fileIO::getFileName());
|
||||||
setFileIndex(fileIO::getFileIndex());
|
setFileIndex(fileIO::getFileIndex());
|
||||||
|
setFileFormat(fileIO::getFileFormat());
|
||||||
pthread_mutex_lock(&ms);
|
pthread_mutex_lock(&ms);
|
||||||
int imask = parentDet->enableWriteToFileMask();
|
int imask = parentDet->enableWriteToFileMask();
|
||||||
pthread_mutex_unlock(&ms);
|
pthread_mutex_unlock(&ms);
|
||||||
@ -7295,6 +7310,48 @@ string slsDetector::setFileName(string s) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
slsReceiverDefs::fileFormat slsDetector::setFileFormat(fileFormat f){
|
||||||
|
int fnum=F_SET_RECEIVER_FILE_FORMAT;
|
||||||
|
int ret = FAIL;
|
||||||
|
int arg = -1;
|
||||||
|
int retval = -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(thisDetector->receiverOnlineFlag==OFFLINE_FLAG){
|
||||||
|
if(f>=0){
|
||||||
|
pthread_mutex_lock(&ms);
|
||||||
|
fileIO::setFileFormat(f);
|
||||||
|
pthread_mutex_unlock(&ms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else{
|
||||||
|
arg = (int)f;
|
||||||
|
#ifdef VERBOSE
|
||||||
|
std::cout << "Sending file format to receiver " << arg << std::endl;
|
||||||
|
#endif
|
||||||
|
if (connectData() == OK){
|
||||||
|
ret=thisReceiver->sendInt(fnum,retval,arg);
|
||||||
|
disconnectData();
|
||||||
|
}
|
||||||
|
if(ret == FAIL)
|
||||||
|
setErrorMask((getErrorMask())|(RECEIVER_FILE_FORMAT));
|
||||||
|
else{
|
||||||
|
pthread_mutex_lock(&ms);
|
||||||
|
fileIO::setFileFormat(retval);
|
||||||
|
pthread_mutex_unlock(&ms);
|
||||||
|
if(ret==FORCE_UPDATE)
|
||||||
|
updateReceiver();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileIO::getFileFormat();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::setFileIndex(int i) {
|
int slsDetector::setFileIndex(int i) {
|
||||||
int fnum=F_SET_RECEIVER_FILE_INDEX;
|
int fnum=F_SET_RECEIVER_FILE_INDEX;
|
||||||
|
@ -270,6 +270,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
/** flipped data across x or y axis */
|
/** flipped data across x or y axis */
|
||||||
int flippedData[2];
|
int flippedData[2];
|
||||||
|
|
||||||
|
|
||||||
} sharedSlsDetector;
|
} sharedSlsDetector;
|
||||||
|
|
||||||
|
|
||||||
@ -1534,6 +1535,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
*/
|
*/
|
||||||
string setFileName(string s="");
|
string setFileName(string s="");
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets up the file format
|
||||||
|
@param f file format
|
||||||
|
\returns file format
|
||||||
|
*/
|
||||||
|
fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets up the file index
|
Sets up the file index
|
||||||
@param i file index
|
@param i file index
|
||||||
@ -1551,6 +1559,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
|
|||||||
*/
|
*/
|
||||||
string getFileName(){return setFileName();};
|
string getFileName(){return setFileName();};
|
||||||
|
|
||||||
|
/**
|
||||||
|
\returns file name
|
||||||
|
*/
|
||||||
|
fileFormat getFileFormat(){return setFileFormat();};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\returns file index
|
\returns file index
|
||||||
*/
|
*/
|
||||||
|
@ -743,6 +743,18 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
|||||||
default: return string("idle"); \
|
default: return string("idle"); \
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
/** returns string from file format index
|
||||||
|
\param s can be RAW, HDF5
|
||||||
|
\returns string raw, hdf5
|
||||||
|
*/
|
||||||
|
static string fileFormats(fileFormat f){\
|
||||||
|
switch (f) { \
|
||||||
|
case BINARY: return string("binary"); \
|
||||||
|
case ASCII: return string("ascii"); \
|
||||||
|
case HDF5: return string("hdf5"); \
|
||||||
|
default: return string("unknown"); \
|
||||||
|
}};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -226,6 +226,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName;
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
descrToFuncMap[i].m_pFuncName="fileformat"; //OK
|
||||||
|
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName;
|
||||||
|
i++;
|
||||||
|
|
||||||
/* Acquisition actions */
|
/* Acquisition actions */
|
||||||
|
|
||||||
descrToFuncMap[i].m_pFuncName="positions"; //
|
descrToFuncMap[i].m_pFuncName="positions"; //
|
||||||
@ -1883,7 +1887,18 @@ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){
|
|||||||
myDet->setFileName(string(args[1]));
|
myDet->setFileName(string(args[1]));
|
||||||
|
|
||||||
return string(myDet->getFileName());
|
return string(myDet->getFileName());
|
||||||
} else
|
} else if(cmd=="fileformat") {
|
||||||
|
if (action==PUT_ACTION){
|
||||||
|
if (string(args[1])=="binary")
|
||||||
|
myDet->setFileFormat(BINARY);
|
||||||
|
else if (string(args[1])=="ascii")
|
||||||
|
myDet->setFileFormat(ASCII);
|
||||||
|
else if (string(args[1])=="hdf5")
|
||||||
|
myDet->setFileFormat(HDF5);
|
||||||
|
else return string("could not scan file format mode\n");
|
||||||
|
}
|
||||||
|
return myDet->fileFormats(myDet->getFileFormat());
|
||||||
|
}
|
||||||
return string(myDet->getCurrentFileName());
|
return string(myDet->getCurrentFileName());
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1892,10 +1907,14 @@ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){
|
|||||||
|
|
||||||
string slsDetectorCommand::helpFileName(int narg, char *args[], int action){
|
string slsDetectorCommand::helpFileName(int narg, char *args[], int action){
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
if (action==GET_ACTION || action==HELP_ACTION)
|
if (action==GET_ACTION || action==HELP_ACTION){
|
||||||
os << string("fname \t gets the filename for the data without index and extension\n");
|
os << string("fname \t gets the filename for the data without index and extension\n");
|
||||||
if (action==PUT_ACTION || action==HELP_ACTION)
|
os << string("fileformat \t gets the file format for data\n");
|
||||||
|
}
|
||||||
|
if (action==PUT_ACTION || action==HELP_ACTION){
|
||||||
os << string("fname s \t sets the filename for the data (index and extension will be automatically appended)\n");
|
os << string("fname s \t sets the filename for the data (index and extension will be automatically appended)\n");
|
||||||
|
os << string("fname s \t sets the file format for the data (binary, ascii, hdf5)\n");
|
||||||
|
}
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,6 +642,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
*/
|
*/
|
||||||
virtual string setFileName(string s="")=0;
|
virtual string setFileName(string s="")=0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets up the file format
|
||||||
|
@param f file format
|
||||||
|
\returns file format
|
||||||
|
*/
|
||||||
|
virtual fileFormat setFileFormat(fileFormat f=GET_FILE_FORMAT)=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\returns file dir
|
\returns file dir
|
||||||
*/
|
*/
|
||||||
@ -652,6 +659,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
|||||||
*/
|
*/
|
||||||
virtual string getFileName()=0;
|
virtual string getFileName()=0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
\returns file name
|
||||||
|
*/
|
||||||
|
virtual fileFormat getFileFormat()=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\returns frames caught by receiver
|
\returns frames caught by receiver
|
||||||
*/
|
*/
|
||||||
|
@ -92,6 +92,15 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
*/
|
*/
|
||||||
virtual int setDetectorIndex(int i) {detIndex=i;return detIndex;};
|
virtual int setDetectorIndex(int i) {detIndex=i;return detIndex;};
|
||||||
|
|
||||||
|
/**
|
||||||
|
sets the default file format
|
||||||
|
\param i file format to be set
|
||||||
|
\returns actual file frame format
|
||||||
|
*/
|
||||||
|
virtual fileFormat setFileFormat(int i) {*fileFormatType=(fileFormat)i; return *fileFormatType;};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\returns the output files path
|
\returns the output files path
|
||||||
|
|
||||||
@ -127,6 +136,11 @@ class fileIO : public fileIOStatic, public virtual slsDetectorBase {
|
|||||||
*/
|
*/
|
||||||
virtual int getFramesPerFile() {return *framesPerFile;};
|
virtual int getFramesPerFile() {return *framesPerFile;};
|
||||||
|
|
||||||
|
/**
|
||||||
|
\returns the max frames per file
|
||||||
|
*/
|
||||||
|
virtual fileFormat getFileFormat() {return *fileFormatType;};
|
||||||
|
|
||||||
|
|
||||||
string createFileName();
|
string createFileName();
|
||||||
|
|
||||||
@ -306,8 +320,8 @@ yes */
|
|||||||
int detIndex;
|
int detIndex;
|
||||||
/** frames per file */
|
/** frames per file */
|
||||||
int *framesPerFile;
|
int *framesPerFile;
|
||||||
|
/** file format */
|
||||||
// int *fileFormat;
|
fileFormat *fileFormatType;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user