included exitReceiver, using different threads to listen and write packets in receiver, edited circularfifo to use pointer references, and acquire returns frames caught

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@362 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2012-11-30 09:28:52 +00:00
parent d8af12456d
commit 6b935f3bd2
12 changed files with 335 additions and 101 deletions

View File

@@ -5805,3 +5805,30 @@ int slsDetector::updateReceiver() {
}
int slsDetector::exitReceiver(){
int retval;
int fnum=F_EXIT_SERVER;
if (setReceiverOnline(ONLINE_FLAG)==ONLINE_FLAG) {
if (dataSocket) {
dataSocket->Connect();
dataSocket->SendDataOnly(&fnum,sizeof(fnum));
dataSocket->ReceiveDataOnly(&retval,sizeof(retval));
dataSocket->Disconnect();
}
}
if (retval!=OK) {
std::cout<< std::endl;
std::cout<< "Shutting down the receiver" << std::endl;
std::cout<< std::endl;
}
return retval;
};

View File

@@ -1496,6 +1496,13 @@ class slsDetector : public slsDetectorUtils, public energyConversion {
/returns OK
*/
int updateReceiver();
/**
Turns off the receiver server!
*/
int exitReceiver();
int fillModuleMask(int *mM);
protected:

View File

@@ -83,6 +83,11 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdExitServer;
i++;
descrToFuncMap[i].m_pFuncName="exitreceiver";//OK
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdExitServer;
i++;
/* data processing commands */
@@ -782,6 +787,11 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
myDet->setOnline(ONLINE_FLAG);
myDet->acquire();
if(myDet->setReceiverOnline()==ONLINE_FLAG){
char answer[100];
sprintf(answer,"\n%d",myDet->getFramesCaughtByReceiver());
return string(answer);
}
return string("");
@@ -1209,19 +1219,32 @@ string slsDetectorCommand::cmdExitServer(int narg, char *args[], int action){
if (action==HELP_ACTION) {
return helpExitServer(narg, args, action);
}
myDet->setOnline(ONLINE_FLAG);
if (action==PUT_ACTION) {
if (myDet->exitServer()!=OK)
return string("Server shut down.");
else
return string("Error closing server\n");
if (cmd=="exitserver"){
myDet->setOnline(ONLINE_FLAG);
if (myDet->exitServer()!=OK)
return string("Server shut down.");
else
return string("Error closing server\n");
}
else if (cmd=="exitreceiver"){
if(myDet->exitReceiver()!=OK)
return string("Receiver shut down\n");
else
return string("Error closing receiver\n");
}
else return("cannot decode command\n");
} else
return ("cannot get");
}
string slsDetectorCommand::helpExitServer(int narg, char *args[], int action){
return string("exitserver \t shuts down all the detector servers. Don't use it!!!!");
ostringstream os;
os << string("exitserver \t shuts down all the detector servers. Don't use it!!!!\n");
os << string("exitreceiver \t shuts down all the receiver servers.\n");
return os.str();
}

View File

@@ -637,6 +637,11 @@ virtual int resetFramesCaught(int index=-1)=0;
virtual int* readFrameFromReceiver(char* fName, int &fIndex)=0;
/**
Turns off the receiver server!
*/
virtual int exitReceiver()=0;
protected:
static const int64_t thisSoftwareVersion=0x20120124;