moving towards c++ api

This commit is contained in:
Dhanya Maliakal
2016-12-12 14:24:11 +01:00
parent a67f9d50de
commit e7621a6cd0
9 changed files with 180 additions and 10 deletions

View File

@@ -863,15 +863,29 @@ int slsDetector::initializeDetectorSize(detectorType type) {
fileName=parentDet->fileName;
fileIndex=parentDet->fileIndex;
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);
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);
if (thisDetector->myDetectorType==JUNGFRAU)
pthread_mutex_unlock(&ms);
setFileFormat(BINARY);
}else if (thisDetector->myDetectorType==JUNGFRAU){
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);
pthread_mutex_unlock(&ms);
pthread_mutex_unlock(&ms);
setFileFormat(BINARY);
}else
pthread_mutex_unlock(&ms);
thisReceiver = new receiverInterface(dataSocket);
// setAngularConversionPointer(thisDetector->angOff,&thisDetector->nMods, thisDetector->nChans*thisDetector->nChips);
@@ -5640,6 +5654,7 @@ char* slsDetector::setReceiver(string receiverIP){
setFilePath(fileIO::getFilePath());
setFileName(fileIO::getFileName());
setFileIndex(fileIO::getFileIndex());
setFileFormat(fileIO::getFileFormat());
pthread_mutex_lock(&ms);
int imask = parentDet->enableWriteToFileMask();
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 fnum=F_SET_RECEIVER_FILE_INDEX;

View File

@@ -270,6 +270,7 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
/** flipped data across x or y axis */
int flippedData[2];
} sharedSlsDetector;
@@ -1534,6 +1535,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
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
@param i file index
@@ -1551,6 +1559,11 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
*/
string getFileName(){return setFileName();};
/**
\returns file name
*/
fileFormat getFileFormat(){return setFileFormat();};
/**
\returns file index
*/

View File

@@ -743,6 +743,18 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
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"); \
}};
};

View File

@@ -226,6 +226,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName;
i++;
descrToFuncMap[i].m_pFuncName="fileformat"; //OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdFileName;
i++;
/* Acquisition actions */
descrToFuncMap[i].m_pFuncName="positions"; //
@@ -1883,7 +1887,18 @@ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){
myDet->setFileName(string(args[1]));
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());
}
@@ -1892,10 +1907,14 @@ string slsDetectorCommand::cmdFileName(int narg, char *args[], int action){
string slsDetectorCommand::helpFileName(int narg, char *args[], int action){
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");
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 file format for the data (binary, ascii, hdf5)\n");
}
return os.str();
}

View File

@@ -642,6 +642,13 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/
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
*/
@@ -652,6 +659,11 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/
virtual string getFileName()=0;
/**
\returns file name
*/
virtual fileFormat getFileFormat()=0;
/**
\returns frames caught by receiver
*/