From ef8455ced64ab97ce648e965fc7c2f1844a0cf04 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Mon, 10 Sep 2012 09:31:32 +0000 Subject: [PATCH] added a new function checkOnline to check individually if det is connected git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@243 951219d9-93cf-4727-9268-0efd64621fa3 --- .../multiSlsDetector/multiSlsDetector.cpp | 28 +++++++++++++++---- .../multiSlsDetector/multiSlsDetector.h | 7 +++++ .../slsDetector/slsDetector.cpp | 25 +++++++++++++++++ slsDetectorSoftware/slsDetector/slsDetector.h | 2 ++ 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index acfae500b..3c25906a9 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -884,6 +884,26 @@ int multiSlsDetector::setOnline(int off) { }; + +int multiSlsDetector::checkOnline() { + int ret1=-100,ret; + for (int idet=0; idetnumberOfDetectors; idet++) { + if (detectors[idet]) { + ret=detectors[idet]->checkOnline(); + cout<<"ret:"<alreadyExisting; } @@ -891,8 +911,6 @@ int multiSlsDetector::exists() { - - // Initialization functions @@ -1941,15 +1959,15 @@ double multiSlsDetector::getRateCorrectionTau(){ ret1=ret; else if (ret!=ret1) ret1=-1; - } - } + } + } } else { #ifdef VERBOSE std::cout<< "Rate correction is disabled " << std::endl; #endif ret1=0; } - return ret1; + return ret1; }; diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 97cb3b4fe..3f0a78f2f 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -356,6 +356,13 @@ class multiSlsDetector : public slsDetectorUtils { \returns online/offline status */ int setOnline(int const online=GET_ONLINE_FLAG); + + /** 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(); + + /** \returns 1 if the detector structure has already be initlialized with the given id and belongs to this multiDetector instance, 0 otherwise */ int exists(); diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 80d24018d..9968ae2c9 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -908,6 +908,31 @@ 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; +#ifdef VERBOSE + std::cout<< "offline!" << std::endl; +#endif + } else { + thisDetector->onlineFlag=ONLINE_FLAG; + controlSocket->SetTimeOut(100); + controlSocket->Disconnect(); +#ifdef VERBOSE + std::cout<< "online!" << std::endl; +#endif + } + return retval; +} + + /* configure the socket communication and check that the server exists diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index b187fd955..a1702ea43 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -284,6 +284,8 @@ typedef struct sharedSlsDetector { int setOnline(int const online=GET_ONLINE_FLAG); + int checkOnline(); + /** returns if the detector already existed \returns 1 if the detector structure has already be initlialized, 0 otherwise */ int exists() {return thisDetector->alreadyExisting;};