From 8b3c4c21eb73059ee445d41350a75795df236a4e Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Wed, 3 Oct 2012 12:43:17 +0000 Subject: [PATCH] update frames caught git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@282 951219d9-93cf-4727-9268-0efd64621fa3 --- .../commonFiles/sls_detector_funcs.h | 4 +- .../multiSlsDetector/multiSlsDetector.cpp | 23 ++++++- .../multiSlsDetector/multiSlsDetector.h | 5 ++ .../slsDetector/slsDetector.cpp | 33 ++++++++++ slsDetectorSoftware/slsDetector/slsDetector.h | 6 ++ .../slsDetector/slsDetectorBase.h | 5 ++ .../slsDetector/slsDetectorCommand.cpp | 65 +++++++++++++------ 7 files changed, 117 insertions(+), 24 deletions(-) diff --git a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h index 5a1336370..636d11b72 100644 --- a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h @@ -115,7 +115,9 @@ enum { F_STOP_RECEIVER, /**< stops the receiver listening mode */ - F_GET_RECEIVER_STATUS /**< gets the status of receiver listening mode */ + F_GET_RECEIVER_STATUS, /**< gets the status of receiver listening mode */ + + F_GET_FRAMES_CAUGHT /**< gets the number of frames caught by receiver */ /* Always append functions hereafter!!! */ diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 228cb9c41..674752d5a 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -874,7 +874,7 @@ int multiSlsDetector::setOnline(int off) { if (off!=GET_ONLINE_FLAG) { thisMultiDetector->onlineFlag=off; - for (int i=0; inumberOfDetectors+1; i++) { + for (int i=0; inumberOfDetectors; i++) { if (detectors[i]) detectors[i]->setOnline(off); } @@ -3561,7 +3561,7 @@ int multiSlsDetector::readDataFile(string fname, int *data) { int multiSlsDetector::setReceiverOnline(int off) { if (off!=GET_ONLINE_FLAG) { int ret=-100,ret1; - for (int i=0; inumberOfDetectors+1; i++) + for (int i=0; inumberOfDetectors; i++) if (detectors[i]){ ret1=detectors[i]->setReceiverOnline(off); if(ret==-100) @@ -3717,3 +3717,22 @@ slsDetectorDefs::runStatus multiSlsDetector::getReceiverStatus(){ } + + + +int multiSlsDetector::getFramesCaughtByReciver() { + int ret=-100,ret1; + for (int i=0; inumberOfDetectors; i++) + if (detectors[i]){ + ret1=detectors[i]->getFramesCaughtByReciver(); + if(ret==-100) + ret=ret1; + else if (ret!=ret1) + ret=-1; + } + + return ret; +} + + + diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 3b4722e80..4a476bc2d 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1058,6 +1058,11 @@ class multiSlsDetector : public slsDetectorUtils { */ runStatus getReceiverStatus(); + /** gets the number of frames caught by receiver + \returns number of frames caught by receiver + */ + int getFramesCaughtByReciver(); + protected: diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index a07fc0c82..bb16873da 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -5642,3 +5642,36 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus(){ return retval; } + + + +int slsDetector::getFramesCaughtByReciver(){ + int fnum=F_GET_FRAMES_CAUGHT; + int ret = FAIL; + char mess[100]; + int retval=-1; + +#ifdef VERBOSE + std::cout << "Starting Receiver " << std::endl; +#endif + + if (thisDetector->receiverOnlineFlag==ONLINE_FLAG) { + if (dataSocket) { + if (dataSocket->Connect()>=0) { + dataSocket->SendDataOnly(&fnum,sizeof(fnum)); + dataSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret!=FAIL) + dataSocket->ReceiveDataOnly(&retval,sizeof(retval)); + else{ + dataSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Receiver returned error: " << mess << std::endl; + } + dataSocket->Disconnect(); + /*if (ret==FORCE_UPDATE) + updateReceiver();*/ + } + } + } + return retval; +} + diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 100c16d26..926e51dc3 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -1423,6 +1423,12 @@ typedef struct sharedSlsDetector { */ runStatus getReceiverStatus(); + /** gets the number of frames caught by receiver + \returns number of frames caught by receiver + */ + int getFramesCaughtByReciver(); + + protected: diff --git a/slsDetectorSoftware/slsDetector/slsDetectorBase.h b/slsDetectorSoftware/slsDetector/slsDetectorBase.h index d955d4721..c8a11d86c 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorBase.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorBase.h @@ -472,6 +472,11 @@ int64_t setNumberOfCycles(int64_t t=-1){return setTimer(CYCLES_NUMBER,t);}; */ virtual runStatus getReceiverStatus()=0; + /** gets the number of frames caught by receiver + \returns number of frames caught by receiver + */ + virtual int getFramesCaughtByReciver()=0; + /** returns detector type string from detector type index \param t string can be Mythen, Pilatus, Eiger, Gotthard, Agipd, Unknown diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index dcf09f54f..c1eeec828 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -651,6 +651,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline; i++; + descrToFuncMap[i].m_pFuncName="framescaught"; + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdReceiver; + i++; + numberOfCommands=i; @@ -1433,8 +1437,11 @@ string slsDetectorCommand::cmdFileIndex(int narg, char *args[], int action){ } } - if(receiver) + if(receiver){ + //int ret=myDet->setReceiverFileIndex(); + //myDet->setFileIndex(ret); sprintf(ans,"%d", myDet->setReceiverFileIndex()); + } else sprintf(ans,"%d", myDet->getFileIndex()); @@ -3481,33 +3488,48 @@ string slsDetectorCommand::helpConfiguration(int narg, char *args[], int action) string slsDetectorCommand::cmdReceiver(int narg, char *args[], int action) { + char answer[100]; + if (action==HELP_ACTION) return helpReceiver(narg, args, action); if(myDet->setReceiverOnline(ONLINE_FLAG)!=ONLINE_FLAG) return string("receiver not online"); - if (action==PUT_ACTION) { - if(!strcasecmp(args[1],"start")){ - //update receiver index - if(myDet->setReceiverFileIndex(myDet->getFileIndex())==-1) - return string("could not set receiver file index"); - myDet->startReceiver(); - } - - else if(!strcasecmp(args[1],"stop")){ - if(myDet->stopReceiver()!=FAIL){ - //update index - int index = myDet->setReceiverFileIndex(); - if(index==-1) - return string("could not get receiver file index"); - myDet->setFileIndex(index); + if(cmd=="receiver"){ + if (action==PUT_ACTION) { + if(!strcasecmp(args[1],"start")){ + //update receiver index + if(myDet->setReceiverFileIndex(myDet->getFileIndex())==-1) + return string("could not set receiver file index"); + myDet->startReceiver(); } - }else - return helpReceiver(narg, args, action); + + else if(!strcasecmp(args[1],"stop")){ + if(myDet->stopReceiver()!=FAIL){ + //update index + int index = myDet->setReceiverFileIndex(); + if(index==-1) + return string("could not get receiver file index"); + myDet->setFileIndex(index); + } + }else + return helpReceiver(narg, args, action); + } + return myDet->runStatusType(myDet->getReceiverStatus()); } - return myDet->runStatusType(myDet->getReceiverStatus()); + else if(cmd=="framescaught"){ + if (action==PUT_ACTION) + return string("cannot put"); + else{ + sprintf(answer,"%d",myDet->getFramesCaughtByReciver()); + return string(answer); + } + } + else + return string("could not decode command"); + } @@ -3517,9 +3539,10 @@ string slsDetectorCommand::helpReceiver(int narg, char *args[], int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) os << "receiver [status] \t starts/stops the receiver to listen to detector packets. - can be start or stop" << std::endl; - if (action==GET_ACTION || action==HELP_ACTION) + if (action==GET_ACTION || action==HELP_ACTION){ os << "receiver \t returns the status of receiver - can be running or idle" << std::endl; - + os << "framescaught \t returns the number of frames caught by receiver" << std::endl; + } return os.str();