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