mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-06 01:50:40 +02:00
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:
parent
2cfdc2b108
commit
5cb68d870e
@ -885,19 +885,18 @@ int multiSlsDetector::setOnline(int off) {
|
||||
|
||||
|
||||
|
||||
int multiSlsDetector::checkOnline() {
|
||||
int ret1=-100,ret;
|
||||
string multiSlsDetector::checkOnline() {
|
||||
string retval1 = "",retval;
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||
if (detectors[idet]) {
|
||||
ret=detectors[idet]->checkOnline();
|
||||
cout<<"ret:"<<ret<<endl;
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1)
|
||||
ret1=-1;
|
||||
retval=detectors[idet]->checkOnline();
|
||||
if(!retval.empty()){
|
||||
retval1.append(retval);
|
||||
retval1.append("+");
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret1;
|
||||
return retval1;
|
||||
};
|
||||
|
||||
|
||||
|
@ -360,7 +360,7 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
/** 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
|
||||
*/
|
||||
int checkOnline();
|
||||
string checkOnline();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "slsDetector.h"
|
||||
#include "usersFunctions.h"
|
||||
#include "slsDetectorCommand.h"
|
||||
@ -908,26 +907,35 @@ int slsDetector::setOnline(int off) {
|
||||
|
||||
|
||||
|
||||
int slsDetector::checkOnline() {
|
||||
int retval=ONLINE_FLAG;
|
||||
if(!controlSocket)
|
||||
controlSocket= new MySocketTCP(thisDetector->hostname, thisDetector->controlPort);
|
||||
if (controlSocket->Connect()<0) {
|
||||
controlSocket->SetTimeOut(5);
|
||||
thisDetector->onlineFlag=OFFLINE_FLAG;
|
||||
delete controlSocket;
|
||||
controlSocket=NULL;
|
||||
retval=OFFLINE_FLAG;
|
||||
string slsDetector::checkOnline() {
|
||||
string retval = "";
|
||||
if(!controlSocket){
|
||||
//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) {
|
||||
controlSocket->SetTimeOut(5);
|
||||
thisDetector->onlineFlag=OFFLINE_FLAG;
|
||||
delete controlSocket;
|
||||
controlSocket=NULL;
|
||||
retval = thisDetector->hostname;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "offline!" << std::endl;
|
||||
std::cout<< "offline!" << std::endl;
|
||||
#endif
|
||||
} else {
|
||||
thisDetector->onlineFlag=ONLINE_FLAG;
|
||||
controlSocket->SetTimeOut(100);
|
||||
controlSocket->Disconnect();
|
||||
} else {
|
||||
thisDetector->onlineFlag=ONLINE_FLAG;
|
||||
controlSocket->SetTimeOut(100);
|
||||
controlSocket->Disconnect();
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "online!" << std::endl;
|
||||
std::cout<< "online!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -970,7 +978,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
}
|
||||
} else
|
||||
strcpy(thisName,thisDetector->hostname);
|
||||
|
||||
|
||||
if (control_port>0) {
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "setting control port" << std::endl;
|
||||
|
@ -284,7 +284,7 @@ typedef struct sharedSlsDetector {
|
||||
|
||||
int setOnline(int const online=GET_ONLINE_FLAG);
|
||||
|
||||
int checkOnline();
|
||||
string checkOnline();
|
||||
|
||||
/** returns if the detector already existed
|
||||
\returns 1 if the detector structure has already be initlialized, 0 otherwise */
|
||||
|
@ -183,6 +183,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="checkonline"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
|
||||
i++;
|
||||
|
||||
descrToFuncMap[i].m_pFuncName="enablefwrite"; //
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdEnablefwrite;
|
||||
i++;
|
||||
@ -2233,13 +2237,23 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
|
||||
}
|
||||
int ival;
|
||||
char ans[1000];
|
||||
if (action==PUT_ACTION) {
|
||||
if (sscanf(args[1],"%d",&ival))
|
||||
myDet->setOnline(ival);
|
||||
else
|
||||
return string("Could not scan online mode ")+string(args[1]);
|
||||
|
||||
if(cmd=="online"){
|
||||
if (action==PUT_ACTION) {
|
||||
if (sscanf(args[1],"%d",&ival))
|
||||
myDet->setOnline(ival);
|
||||
else
|
||||
return string("Could not scan online mode ")+string(args[1]);
|
||||
}
|
||||
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");
|
||||
}
|
||||
sprintf(ans,"%d",myDet->setOnline());
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
@ -194,6 +194,12 @@ class slsDetectorUtils : public slsDetectorActions, public postProcessing {
|
||||
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
|
||||
\param mode test mode
|
||||
\param imod module number for chip test or module firmware test
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user