modified receiver to save a simpler file name for sebastian, set receiver port modified

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@355 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2012-11-22 10:25:42 +00:00
parent 2580c29886
commit 6a74fda3ed
6 changed files with 181 additions and 143 deletions

View File

@ -15,16 +15,24 @@ int main(int argc, char *argv[])
int ret = slsDetectorDefs::OK;
MySocketTCP *socket = NULL;
string fname = "";
bool shortfname = false;
//parse command line for config
for(int iarg=2;iarg<argc;iarg++)
if(!strcasecmp(argv[iarg-1],"-config"))
for(int iarg=1;iarg<argc;iarg++){
if(!strcasecmp(argv[iarg],"-config")){
if(iarg+1==argc){
cout << "no config file name given. Exiting." << endl;
return -1;
}
fname.assign(argv[iarg]);
}
if(!strcasecmp(argv[iarg],"-shortfname"))
shortfname = true;
}
//reads config file, creates socket, assigns function table
slsReceiverFuncs *receiver = new slsReceiverFuncs(socket,fname,ret);
slsReceiverFuncs *receiver = new slsReceiverFuncs(socket,fname,ret, shortfname);
if(ret==slsDetectorDefs::FAIL)
return -1;

View File

@ -23,7 +23,8 @@ using namespace std;
FILE* slsReceiverFunctionList::sfilefd(NULL);
int slsReceiverFunctionList::listening_thread_running(0);
slsReceiverFunctionList::slsReceiverFunctionList():
slsReceiverFunctionList::slsReceiverFunctionList(bool shortfname):
shortFileName(shortfname),
fileIndex(0),
frameIndexNeeded(true),
framesCaught(0),
@ -38,6 +39,7 @@ slsReceiverFunctionList::slsReceiverFunctionList():
server_port(DEFAULT_UDP_PORT)
{
strcpy(savefilename,"");
strcpy(actualfilename,"");
strcpy(filePath,"");
strcpy(fileName,"run");
strcpy(buffer,"");
@ -195,6 +197,10 @@ int slsReceiverFunctionList::startListening(){
else
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,framesCaught,fileIndex);
if(!shortFileName)
strcpy(actualfilename,savefilename);
else
sprintf(actualfilename, "%s/%s_%d_%012d.raw", filePath,fileName,fileIndex, framesCaught);
// 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
@ -206,8 +212,8 @@ int slsReceiverFunctionList::startListening(){
break;
}
sfilefd = fopen((const char *) (savefilename), "w");
cout << "Saving to " << savefilename << ". Ready! " << endl;
sfilefd = fopen((const char *) (actualfilename), "w");
cout << "Saving to " << actualfilename << ". Ready! " << endl;
while (listening_thread_running) {
@ -221,10 +227,15 @@ int slsReceiverFunctionList::startListening(){
else
sprintf(savefilename, "%s/%s_f%012d_%d.raw", filePath,fileName,framesCaught,fileIndex);
cout << "saving to " << savefilename << "\t\t"
if(!shortFileName)
strcpy(actualfilename,savefilename);
else
sprintf(actualfilename, "%s/%s_%d_%012d.raw", filePath,fileName,fileIndex, framesCaught);
cout << "saving to " << actualfilename << "\t\t"
"packet loss " << ((currframenum-prevframenum-(2*framesInFile))/(double)(2*framesInFile))*100.000 << "%\t\t"
"framenum " << currframenum << endl;
sfilefd = fopen((const char *) (savefilename), "w");
sfilefd = fopen((const char *) (actualfilename), "w");
prevframenum=currframenum;
framesInFile = 0;
}

View File

@ -21,8 +21,9 @@ class slsReceiverFunctionList : private virtual slsDetectorDefs {
public:
/**
* Constructor
* @param shortfname true if short file name required
*/
slsReceiverFunctionList();
slsReceiverFunctionList(bool shortfname);
/**
* Destructor
@ -142,6 +143,12 @@ 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*/
bool shortFileName;
/** File Name without frame index, file index and extension*/
char fileName[MAX_STR_LENGTH];

View File

@ -13,7 +13,7 @@
using namespace std;
slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int &success):
slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int &success, bool shortfname):
socket(mySocket),
ret(OK),
lockStatus(0){
@ -89,7 +89,7 @@ slsReceiverFuncs::slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int
strcpy(mess,"dummy message");
function_table();
slsReceiverList = new slsReceiverFunctionList();
slsReceiverList = new slsReceiverFunctionList(shortfname);
success = OK;
}

View File

@ -25,8 +25,9 @@ public:
* @param mySocket tcp socket connecting receiver and client
* @param fname name of config file
* @param success if socket creation was successfull
* @param shortfname true if short file name required
*/
slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int &success);
slsReceiverFuncs(MySocketTCP *&mySocket,string const fname,int &success, bool shortfname);
/** Destructor */
virtual ~slsReceiverFuncs(){};