mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 15:50:03 +02:00
got rid of short file name
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@485 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
96d9e5d078
commit
91e5e35c73
@ -1,5 +1,5 @@
|
||||
CC = g++
|
||||
CLAGS += -DSLS_RECEIVER_FUNCTION_LIST -DGOTTHARDD -DUHRIXCALLBACK #-DTESTWRITE
|
||||
CLAGS += -DSLS_RECEIVER_FUNCTION_LIST -DGOTTHARDD #-DUHRIXCALLBACK #-DTESTWRITE
|
||||
LDLIBS += -lm -lstdc++ -lpthread
|
||||
|
||||
INCLUDES = -I ../MySocketTCP -I ../commonFiles -I ../usersFunctions -I ../slsDetectorAnalysis -I .
|
||||
|
@ -31,11 +31,9 @@ using namespace std;
|
||||
FILE* slsReceiverFunctionList::sfilefd(NULL);
|
||||
int slsReceiverFunctionList::listening_thread_running(0);
|
||||
|
||||
slsReceiverFunctionList::slsReceiverFunctionList(bool shortfname):
|
||||
slsReceiverFunctionList::slsReceiverFunctionList():
|
||||
maxFramesPerFile(MAX_FRAMES),
|
||||
enableFileWrite(1),
|
||||
shortFileName(shortfname),
|
||||
shortFileNameIndex(0),
|
||||
fileIndex(0),
|
||||
frameIndexNeeded(0),
|
||||
framesCaught(0),
|
||||
@ -67,7 +65,6 @@ slsReceiverFunctionList::slsReceiverFunctionList(bool shortfname):
|
||||
|
||||
{
|
||||
strcpy(savefilename,"");
|
||||
strcpy(actualfilename,"");
|
||||
strcpy(filePath,"");
|
||||
strcpy(fileName,"run");
|
||||
eth = new char[MAX_STR_LENGTH];
|
||||
@ -284,11 +281,10 @@ int slsReceiverFunctionList::startListening(){
|
||||
#endif
|
||||
// Variable and structure definitions
|
||||
int rc;
|
||||
// dataStruct *dataReadFrame;
|
||||
// dataStruct *dataReadFrame;
|
||||
|
||||
//reset variables for each acquisition
|
||||
startFrameIndex=-1;
|
||||
shortFileNameIndex=1;
|
||||
|
||||
|
||||
// A do/while(FALSE) loop is used to make error cleanup easier. The
|
||||
@ -399,8 +395,7 @@ int slsReceiverFunctionList::startWriting(){
|
||||
char *wbuf;
|
||||
|
||||
// Variable and structure definitions
|
||||
int ret,sleepnumber=0;//currframenum,ret;
|
||||
// dataStruct *dataWriteFrame;
|
||||
int ret,sleepnumber=0;
|
||||
char *guiData;
|
||||
//reset variables for each acquisition
|
||||
framesInFile=0;
|
||||
@ -408,15 +403,16 @@ int slsReceiverFunctionList::startWriting(){
|
||||
frameIndex=0;
|
||||
if(sfilefd) sfilefd=0;
|
||||
strcpy(savefilename,"");
|
||||
strcpy(actualfilename,"");
|
||||
|
||||
cout << "Max Frames Per File:" << maxFramesPerFile << endl;
|
||||
if (writeReceiverData)
|
||||
cout << "Note: Data Write has been defined exernally" << endl;
|
||||
cout << "Ready!" << endl;
|
||||
|
||||
//by default, we read/write everything
|
||||
cbAction=2;
|
||||
|
||||
//acquisition start
|
||||
if (startAcquisitionCallBack)
|
||||
cbAction=startAcquisitionCallBack(filePath,fileName,fileIndex,bufferSize,pStartAcquisition);
|
||||
|
||||
@ -426,29 +422,18 @@ int slsReceiverFunctionList::startWriting(){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(enableFileWrite==0 || cbAction==0)
|
||||
cout << endl << "Note: Data will not be saved" << endl;
|
||||
|
||||
//create file name
|
||||
if(frameIndexNeeded==-1)
|
||||
sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
||||
else
|
||||
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,framesCaught,fileIndex);
|
||||
if(frameIndexNeeded==-1) sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
||||
else sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,framesCaught,fileIndex);
|
||||
|
||||
//for sebastian
|
||||
if(!shortFileName)
|
||||
strcpy(actualfilename,savefilename);
|
||||
else
|
||||
sprintf(actualfilename, "%s/%s_%d_%09d.raw", filePath,fileName,fileIndex, 0);
|
||||
|
||||
//start writing
|
||||
if(enableFileWrite || cbAction>0){
|
||||
sfilefd = fopen((const char *) (actualfilename), "w");
|
||||
cout << actualfilename << endl;
|
||||
sfilefd = fopen((const char *) (savefilename), "w");
|
||||
cout << savefilename << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -461,19 +446,15 @@ int slsReceiverFunctionList::startWriting(){
|
||||
//create file name
|
||||
if(frameIndexNeeded==-1) sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
||||
else sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,framesCaught,fileIndex);
|
||||
//for sebastian
|
||||
if(!shortFileName) strcpy(actualfilename,savefilename);
|
||||
else sprintf(actualfilename, "%s/%s_%d_%09d.raw", filePath,fileName,fileIndex, shortFileNameIndex);
|
||||
shortFileNameIndex++;
|
||||
|
||||
//start writing in new file
|
||||
if(enableFileWrite || cbAction>0){
|
||||
fclose(sfilefd);
|
||||
sfilefd = fopen((const char *) (actualfilename), "w");
|
||||
sfilefd = fopen((const char *) (savefilename), "w");
|
||||
}
|
||||
|
||||
//currframenum=(int)(*((int*)latestData));
|
||||
cout << actualfilename << "\tpacket loss " << fixed << setprecision(4) << ((currframenum-prevframenum-(packetsPerFrame*framesInFile))/(double)(packetsPerFrame*framesInFile))*100.000 << "%\t\t"
|
||||
cout << savefilename << "\tpacket loss " << fixed << setprecision(4) << ((currframenum-prevframenum-(packetsPerFrame*framesInFile))/(double)(packetsPerFrame*framesInFile))*100.000 << "%\t\t"
|
||||
"framenum " << currframenum << "\t\t"
|
||||
"p " << prevframenum << endl;
|
||||
|
||||
@ -485,13 +466,10 @@ int slsReceiverFunctionList::startWriting(){
|
||||
|
||||
//actual writing from fifo
|
||||
if(!fifo->isEmpty()){
|
||||
// dataWriteFrame = new dataStruct;
|
||||
//if(fifo->pop(dataWriteFrame)){
|
||||
|
||||
if(fifo->pop(wbuf)){
|
||||
//cout<<"write buffer:"<<dataWriteFrame<<endl<<endl;
|
||||
framesCaught++;
|
||||
totalFramesCaught++;
|
||||
//currframenum = (int)(*((int*)dataWriteFrame->buffer));
|
||||
currframenum = (int)(*((int*)wbuf));
|
||||
if(guiRequiresData) {
|
||||
guiData=latestData;
|
||||
@ -499,6 +477,7 @@ int slsReceiverFunctionList::startWriting(){
|
||||
guiData=NULL;
|
||||
}
|
||||
|
||||
//write data
|
||||
if(enableFileWrite){
|
||||
if (writeReceiverData) {
|
||||
writeReceiverData(wbuf,bufferSize, sfilefd, pwriteReceiverDataArg);
|
||||
@ -517,9 +496,8 @@ int slsReceiverFunctionList::startWriting(){
|
||||
//memcpy(latestData,wbuf,bufferSize);
|
||||
guiRequiresData=0;
|
||||
}
|
||||
//cout<<"write index:"<<(int)(*(int*)latestData)<<endl;
|
||||
|
||||
framesInFile++;
|
||||
///ANNA?!?!??!
|
||||
// delete [] dataWriteFrame->buffer;
|
||||
fifofree->push(wbuf);
|
||||
}
|
||||
@ -533,14 +511,14 @@ int slsReceiverFunctionList::startWriting(){
|
||||
|
||||
cout << "Total Frames Caught:"<< totalFramesCaught << endl;
|
||||
//close file
|
||||
|
||||
|
||||
if(sfilefd) fclose(sfilefd);
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "sfield:" << (int)sfilefd << endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//acquistion over
|
||||
if (acquisitionFinishedCallBack)
|
||||
acquisitionFinishedCallBack(totalFramesCaught, pAcquisitionFinished);
|
||||
|
||||
|
@ -25,9 +25,8 @@ class slsReceiverFunctionList : private virtual slsDetectorDefs {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param shortfname true if short file name required
|
||||
*/
|
||||
slsReceiverFunctionList(bool shortfname);
|
||||
slsReceiverFunctionList();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -199,15 +198,6 @@ private:
|
||||
/** Complete File name */
|
||||
char savefilename[MAX_STR_LENGTH];
|
||||
|
||||
/** Actual Complete File name. This is used if you need a simple filename */
|
||||
char actualfilename[MAX_STR_LENGTH];
|
||||
|
||||
/** if short file name is needed, filename= filepath/filename_fileindex_shortFileNameIndex.raw */
|
||||
bool shortFileName;
|
||||
|
||||
/** If short file name is used, different index used instead of frame index */
|
||||
int shortFileNameIndex;
|
||||
|
||||
/** File Name without frame index, file index and extension*/
|
||||
char fileName[MAX_STR_LENGTH];
|
||||
|
||||
|
@ -44,7 +44,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
success=slsDetectorDefs::OK;
|
||||
|
||||
string fname = "";
|
||||
bool shortfname = false;
|
||||
|
||||
//parse command line for config
|
||||
for(int iarg=1;iarg<argc;iarg++){
|
||||
@ -55,8 +54,6 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
}
|
||||
fname.assign(argv[iarg+1]);
|
||||
}
|
||||
if(!strcasecmp(argv[iarg],"-shortfname"))
|
||||
shortfname = true;
|
||||
}
|
||||
|
||||
if(!fname.empty()){
|
||||
@ -123,7 +120,7 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
||||
strcpy(mess,"dummy message");
|
||||
|
||||
function_table();
|
||||
slsReceiverList = new slsReceiverFunctionList(shortfname);
|
||||
slsReceiverList = new slsReceiverFunctionList();
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "Function table assigned." << endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user