diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver.cpp b/slsDetectorSoftware/slsReceiver/slsReceiver.cpp index 0865eb2a9..c353a7d3d 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiver.cpp @@ -31,6 +31,7 @@ int main(int argc, char *argv[]) } + //reads config file, creates socket, assigns function table slsReceiverFuncs *receiver = new slsReceiverFuncs(socket,fname,ret, shortfname); if(ret==slsDetectorDefs::FAIL) diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp index e5f554795..5ce9ad6b5 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp @@ -25,6 +25,7 @@ int slsReceiverFunctionList::listening_thread_running(0); slsReceiverFunctionList::slsReceiverFunctionList(bool shortfname): shortFileName(shortfname), + shortFileNameIndex(0), fileIndex(0), frameIndexNeeded(true), framesCaught(0), @@ -185,7 +186,7 @@ int slsReceiverFunctionList::startListening(){ framesCaught=0; startFrameIndex=-1; frameIndex=0; - + shortFileNameIndex=1; //Catch signal SIGINT to close files properly signal(SIGINT,closeFile); @@ -200,7 +201,7 @@ int slsReceiverFunctionList::startListening(){ if(!shortFileName) strcpy(actualfilename,savefilename); else - sprintf(actualfilename, "%s/%s_%d_%012d.raw", filePath,fileName,fileIndex, framesCaught); + sprintf(actualfilename, "%s/%s_%d_%09d.raw", filePath,fileName,fileIndex, 0); // A do/while(FALSE) loop is used to make error cleanup easier. The // close() of each of the socket descriptors is only done once at the @@ -230,7 +231,9 @@ int slsReceiverFunctionList::startListening(){ if(!shortFileName) strcpy(actualfilename,savefilename); else - sprintf(actualfilename, "%s/%s_%d_%012d.raw", filePath,fileName,fileIndex, framesCaught); + sprintf(actualfilename, "%s/%s_%d_%09d.raw", filePath,fileName,fileIndex, shortFileNameIndex); + + shortFileNameIndex++; cout << "saving to " << actualfilename << "\t\t" "packet loss " << ((currframenum-prevframenum-(2*framesInFile))/(double)(2*framesInFile))*100.000 << "%\t\t" diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h index 4188fa1ca..1a8a844e3 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.h @@ -146,9 +146,12 @@ private: /** Actual Complete File name. This is used if you need a simple filename */ char actualfilename[MAX_STR_LENGTH]; - /** if short file name is needed*/ + /** 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]; diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp index 5fb1b608b..fb372ee9c 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.cpp @@ -6,6 +6,8 @@ #include "slsReceiver_funcs.h" #include "slsReceiverFunctionList.h" +#include // SIGINT + #include #include #include @@ -91,6 +93,9 @@ slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int function_table(); slsReceiverList = new slsReceiverFunctionList(shortfname); + //Catch signal SIGINT to close files properly + //signal(SIGINT,closeFile); + success = OK; } } @@ -189,6 +194,15 @@ int slsReceiverFuncs::M_nofunc(){ +/* +void slsReceiverFuncs::closeFile(int p){ + //if(socket) + slsReceiverFunctionList::closeFile(0); + socket->Disconnect();//non static + delete socket; + exit(0); +} +*/ int slsReceiverFuncs::set_file_name() { diff --git a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h index 7e0bdc245..5eaeef2c9 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h +++ b/slsDetectorSoftware/slsReceiver/slsReceiver_funcs.h @@ -41,6 +41,9 @@ public: /** Unrecognized Function */ int M_nofunc(); + /** Close File */ + //static void closeFile(int p); + /** Set File name without frame index, file index and extension */ int set_file_name();