diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 3c25906a9..873359d87 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -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; idetnumberOfDetectors; idet++) { if (detectors[idet]) { - ret=detectors[idet]->checkOnline(); - cout<<"ret:"<checkOnline(); + if(!retval.empty()){ + retval1.append(retval); + retval1.append("+"); + } } } - return ret1; + return retval1; }; diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 3f0a78f2f..30b36a882 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -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(); /** diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 401745614..4470aa2f1 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -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; diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index a1702ea43..13a6208b4 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -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 */ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 1353d7958..13eb391cb 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -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; } diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index ead657c0d..c92940afb 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -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 diff --git a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.o b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.o index 7290b57ae..0bc7d3b3d 100644 Binary files a/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.o and b/slsDetectorSoftware/slsDetectorAnalysis/angularConversionStatic.o differ