checkOnline works properly now and calls tcpsocket if controlsocket not defined

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@245 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2012-09-10 15:15:43 +00:00
parent 2cfdc2b108
commit 5cb68d870e
7 changed files with 62 additions and 35 deletions

View File

@ -885,19 +885,18 @@ int multiSlsDetector::setOnline(int off) {
int multiSlsDetector::checkOnline() { string multiSlsDetector::checkOnline() {
int ret1=-100,ret; string retval1 = "",retval;
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) { for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
if (detectors[idet]) { if (detectors[idet]) {
ret=detectors[idet]->checkOnline(); retval=detectors[idet]->checkOnline();
cout<<"ret:"<<ret<<endl; if(!retval.empty()){
if (ret1==-100) retval1.append(retval);
ret1=ret; retval1.append("+");
else if (ret!=ret1)
ret1=-1;
} }
} }
return ret1; }
return retval1;
}; };

View File

@ -360,7 +360,7 @@ class multiSlsDetector : public slsDetectorUtils {
/** checks if each of the detectors are online /** checks if each of the detectors are online
\returns online/offline status and -1 if any of the detector's online status is different from the other \returns online/offline status and -1 if any of the detector's online status is different from the other
*/ */
int checkOnline(); string checkOnline();
/** /**

View File

@ -1,4 +1,3 @@
#include "slsDetector.h" #include "slsDetector.h"
#include "usersFunctions.h" #include "usersFunctions.h"
#include "slsDetectorCommand.h" #include "slsDetectorCommand.h"
@ -908,16 +907,24 @@ int slsDetector::setOnline(int off) {
int slsDetector::checkOnline() { string slsDetector::checkOnline() {
int retval=ONLINE_FLAG; string retval = "";
if(!controlSocket) if(!controlSocket){
controlSocket= new MySocketTCP(thisDetector->hostname, thisDetector->controlPort); //this already sets the online/offline flag
setTCPSocket();
if(thisDetector->onlineFlag==OFFLINE_FLAG)
return string(thisDetector->hostname);
else
return string("");
}
//still cannot connect to socket, controlSocket=0
if(controlSocket){
if (controlSocket->Connect()<0) { if (controlSocket->Connect()<0) {
controlSocket->SetTimeOut(5); controlSocket->SetTimeOut(5);
thisDetector->onlineFlag=OFFLINE_FLAG; thisDetector->onlineFlag=OFFLINE_FLAG;
delete controlSocket; delete controlSocket;
controlSocket=NULL; controlSocket=NULL;
retval=OFFLINE_FLAG; retval = thisDetector->hostname;
#ifdef VERBOSE #ifdef VERBOSE
std::cout<< "offline!" << std::endl; std::cout<< "offline!" << std::endl;
#endif #endif
@ -929,6 +936,7 @@ int slsDetector::checkOnline() {
std::cout<< "online!" << std::endl; std::cout<< "online!" << std::endl;
#endif #endif
} }
}
return retval; return retval;
} }

View File

@ -284,7 +284,7 @@ typedef struct sharedSlsDetector {
int setOnline(int const online=GET_ONLINE_FLAG); int setOnline(int const online=GET_ONLINE_FLAG);
int checkOnline(); string checkOnline();
/** returns if the detector already existed /** returns if the detector already existed
\returns 1 if the detector structure has already be initlialized, 0 otherwise */ \returns 1 if the detector structure has already be initlialized, 0 otherwise */

View File

@ -183,6 +183,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
i++; i++;
descrToFuncMap[i].m_pFuncName="checkonline"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
i++;
descrToFuncMap[i].m_pFuncName="enablefwrite"; // descrToFuncMap[i].m_pFuncName="enablefwrite"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdEnablefwrite; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdEnablefwrite;
i++; i++;
@ -2233,6 +2237,8 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
} }
int ival; int ival;
char ans[1000]; char ans[1000];
if(cmd=="online"){
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
if (sscanf(args[1],"%d",&ival)) if (sscanf(args[1],"%d",&ival))
myDet->setOnline(ival); myDet->setOnline(ival);
@ -2240,6 +2246,14 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
return string("Could not scan online mode ")+string(args[1]); return string("Could not scan online mode ")+string(args[1]);
} }
sprintf(ans,"%d",myDet->setOnline()); sprintf(ans,"%d",myDet->setOnline());
}//"checkonline"
else{
strcpy(ans,myDet->checkOnline().c_str());
if(!strlen(ans))
strcpy(ans,"All online");
else
strcat(ans," :not online");
}
return ans; return ans;
} }

View File

@ -193,6 +193,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
*/ */
virtual int64_t getId(idMode mode, int imod=0)=0; virtual int64_t getId(idMode mode, int imod=0)=0;
/**
checks if the detector(s) are online/offline
\returns hostname if offline
*/
virtual string checkOnline()=0;
/** /**
Digital test of the modules Digital test of the modules
\param mode test mode \param mode test mode