mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
frame index now is set via the multi and sls and sent to receiver when frames/cycles is set, resetframescaught doesnt decide if frames needed, possible problem in acquire scans,gets #frames/cycles from detector,but needed
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@451 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -31,7 +31,7 @@ slsReceiverFunctionList::slsReceiverFunctionList(bool shortfname):
|
||||
shortFileName(shortfname),
|
||||
shortFileNameIndex(0),
|
||||
fileIndex(0),
|
||||
frameIndexNeeded(true),
|
||||
frameIndexNeeded(0),
|
||||
framesCaught(0),
|
||||
startFrameIndex(-1),
|
||||
frameIndex(0),
|
||||
@ -152,12 +152,10 @@ int slsReceiverFunctionList::setFileIndex(int i){
|
||||
}
|
||||
|
||||
|
||||
bool slsReceiverFunctionList::resetTotalFramesCaught(bool i){
|
||||
frameIndexNeeded = i;
|
||||
void slsReceiverFunctionList::resetTotalFramesCaught(){
|
||||
startAcquisitionIndex = -1;
|
||||
totalFramesCaught = 0;
|
||||
|
||||
return frameIndexNeeded;
|
||||
}
|
||||
|
||||
|
||||
@ -170,7 +168,9 @@ int slsReceiverFunctionList::startReceiver(){
|
||||
|
||||
int err = 0;
|
||||
if(!listening_thread_running){
|
||||
#ifdef VERBOSE
|
||||
cout << "Starting new acquisition threadddd ...." << endl;
|
||||
#endif
|
||||
listening_thread_running=1;
|
||||
|
||||
|
||||
@ -183,8 +183,9 @@ int slsReceiverFunctionList::startReceiver(){
|
||||
cout << "Cant create writing thread. Status:" << status << endl << endl;
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout << "Writing thread created successfully." << endl;
|
||||
|
||||
#endif
|
||||
|
||||
//error creating listenign thread
|
||||
err = 0;
|
||||
@ -200,9 +201,14 @@ int slsReceiverFunctionList::startReceiver(){
|
||||
}
|
||||
|
||||
while(status!=RUNNING);
|
||||
#ifdef VERBOSE
|
||||
cout << "Listening thread created successfully." << endl;
|
||||
#endif
|
||||
|
||||
cout << "Threads created successfully." << endl;
|
||||
}
|
||||
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -211,12 +217,14 @@ int slsReceiverFunctionList::startReceiver(){
|
||||
|
||||
|
||||
int slsReceiverFunctionList::stopReceiver(){
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
cout << "Stopping Receiver" << endl;
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
if(listening_thread_running){
|
||||
#ifdef VERBOSE
|
||||
cout << "Stopping new acquisition threadddd ...." << endl;
|
||||
#endif
|
||||
//stop listening thread
|
||||
listening_thread_running=0;
|
||||
udpSocket->ShutDownSocket();
|
||||
@ -228,7 +236,7 @@ int slsReceiverFunctionList::stopReceiver(){
|
||||
// if(fifo) delete fifo;
|
||||
//if(latestData) delete latestData;/**new*/
|
||||
}
|
||||
cout << "Status:" << status << endl;
|
||||
cout << "Receiver Stoppped.\nStatus:" << status << endl;
|
||||
|
||||
|
||||
return OK;
|
||||
@ -374,18 +382,17 @@ int slsReceiverFunctionList::startWriting(){
|
||||
framesInFile=0;
|
||||
framesCaught=0;
|
||||
frameIndex=0;
|
||||
|
||||
if(sfilefd) sfilefd=0;
|
||||
|
||||
strcpy(savefilename,"");
|
||||
strcpy(actualfilename,"");
|
||||
|
||||
cout << "Max Frames Per File:" << maxFramesPerFile << endl;
|
||||
cout << "Ready!" << endl;
|
||||
|
||||
|
||||
if(enableFileWrite){
|
||||
//create file name
|
||||
if(!frameIndexNeeded) 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);
|
||||
|
||||
//for sebastian
|
||||
@ -398,6 +405,7 @@ int slsReceiverFunctionList::startWriting(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
while(listening_thread_running){
|
||||
|
||||
//when it reaches maxFramesPerFile,start writing new file
|
||||
@ -406,7 +414,7 @@ int slsReceiverFunctionList::startWriting(){
|
||||
if(enableFileWrite){
|
||||
fclose(sfilefd);
|
||||
//create file name
|
||||
if(!frameIndexNeeded) 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);
|
||||
//for sebastian
|
||||
if(!shortFileName) strcpy(actualfilename,savefilename);
|
||||
@ -426,6 +434,8 @@ int slsReceiverFunctionList::startWriting(){
|
||||
framesInFile = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//actual writing from fifo
|
||||
if(!fifo->isEmpty()){
|
||||
// dataWriteFrame = new dataStruct;
|
||||
@ -487,14 +497,14 @@ char* slsReceiverFunctionList::readFrame(char* c){
|
||||
guiRequiresData=0;
|
||||
|
||||
//if no more data //if(guiRequiresData) // retun NULL;
|
||||
|
||||
//cout<<"latestdata:"<<(int)(*(int*)latestData)<<endl;
|
||||
strcpy(c,savefilename);
|
||||
return latestData;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int slsReceiverFunctionList::setShortFrame(int i){
|
||||
shortFrame=i;
|
||||
|
||||
|
@ -105,6 +105,12 @@ public:
|
||||
*/
|
||||
int setFileIndex(int i);
|
||||
|
||||
/**
|
||||
* Set Frame Index Needed
|
||||
* @param i frame index needed
|
||||
*/
|
||||
int setFrameIndexNeeded(int i){frameIndexNeeded = i;};
|
||||
|
||||
/**
|
||||
* Set enable file write
|
||||
* @param i file write enable
|
||||
@ -115,10 +121,9 @@ public:
|
||||
/**
|
||||
* Resets the Total Frames Caught
|
||||
* This is how the receiver differentiates between entire acquisitions
|
||||
* @param i true if frame index in file name is required, else false
|
||||
* Returns frames needed in file name
|
||||
* Returns 0
|
||||
*/
|
||||
bool resetTotalFramesCaught(bool i);
|
||||
void resetTotalFramesCaught();
|
||||
|
||||
/**
|
||||
* Close File
|
||||
@ -208,7 +213,7 @@ private:
|
||||
int fileIndex;
|
||||
|
||||
/** if frame index required in file name */
|
||||
bool frameIndexNeeded;
|
||||
int frameIndexNeeded;
|
||||
|
||||
/** Frames Caught for each real time acquisition (eg. for each scan) */
|
||||
int framesCaught;
|
||||
|
@ -120,6 +120,7 @@ int slsReceiverFuncs::function_table(){
|
||||
flist[F_SET_FILE_NAME] = &slsReceiverFuncs::set_file_name;
|
||||
flist[F_SET_FILE_PATH] = &slsReceiverFuncs::set_file_dir;
|
||||
flist[F_SET_FILE_INDEX] = &slsReceiverFuncs::set_file_index;
|
||||
flist[F_SET_FRAME_INDEX] = &slsReceiverFuncs::set_frame_index;
|
||||
flist[F_SETUP_UDP] = &slsReceiverFuncs::setup_udp;
|
||||
flist[F_START_RECEIVER] = &slsReceiverFuncs::start_receiver;
|
||||
flist[F_STOP_RECEIVER] = &slsReceiverFuncs::stop_receiver;
|
||||
@ -387,6 +388,60 @@ int slsReceiverFuncs::set_file_index() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int slsReceiverFuncs::set_frame_index() {
|
||||
ret=OK;
|
||||
int retval=-1;
|
||||
int index;
|
||||
strcpy(mess,"Could not set frame index\n");
|
||||
|
||||
|
||||
// receive arguments
|
||||
if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0 ){
|
||||
strcpy(mess,"Error reading from socket\n");
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && socket->differentClients==1){//necessary???
|
||||
sprintf(mess,"Receiver locked by %s\n", socket->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else
|
||||
retval=slsReceiverList->setFrameIndexNeeded(index);
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
if(ret!=FAIL)
|
||||
cout << "frame index:" << retval << endl;
|
||||
else
|
||||
cout << mess << endl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(ret==OK && socket->differentClients){
|
||||
cout << "Force update" << endl;
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
// send answer
|
||||
socket->SendDataOnly(&ret,sizeof(ret));
|
||||
if(ret==FAIL)
|
||||
socket->SendDataOnly(mess,sizeof(mess));
|
||||
socket->SendDataOnly(&retval,sizeof(retval));
|
||||
|
||||
//return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int slsReceiverFuncs::setup_udp(){
|
||||
ret=OK;
|
||||
strcpy(mess,"could not set up udp connection");
|
||||
@ -606,18 +661,11 @@ int slsReceiverFuncs::get_frame_index(){
|
||||
|
||||
int slsReceiverFuncs::reset_frames_caught(){
|
||||
ret=OK;
|
||||
int retval=-1;
|
||||
int index=-1;
|
||||
|
||||
strcpy(mess,"Could not reset frames caught\n");
|
||||
|
||||
|
||||
// receive arguments
|
||||
if(socket->ReceiveDataOnly(&index,sizeof(index)) < 0) {;
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_FUNCTION_LIST
|
||||
if (ret==OK) {
|
||||
@ -626,7 +674,7 @@ int slsReceiverFuncs::reset_frames_caught(){
|
||||
ret=FAIL;
|
||||
}
|
||||
else
|
||||
retval=slsReceiverList->resetTotalFramesCaught(index);
|
||||
slsReceiverList->resetTotalFramesCaught();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -639,7 +687,7 @@ int slsReceiverFuncs::reset_frames_caught(){
|
||||
socket->SendDataOnly(&ret,sizeof(ret));
|
||||
if(ret==FAIL)
|
||||
socket->SendDataOnly(mess,sizeof(mess));
|
||||
socket->SendDataOnly(&retval,sizeof(retval));
|
||||
|
||||
//return ok/fail
|
||||
return ret;
|
||||
|
||||
|
@ -56,6 +56,9 @@ public:
|
||||
/** Set File index */
|
||||
int set_file_index();
|
||||
|
||||
/** Set Frame index */
|
||||
int set_frame_index();
|
||||
|
||||
/** Start Receiver - starts listening to udp packets from detector */
|
||||
int start_receiver();
|
||||
|
||||
|
Reference in New Issue
Block a user