From e49f97a03c8680312056cd1a72d1f6d7191daed6 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Wed, 19 Oct 2016 08:10:42 +0200 Subject: [PATCH] done showing error when detectors not added in sharedmemory due to connect failure --- slsDetectorSoftware/commonFiles/error_defs.h | 30 +++++++++++++++++-- .../multiSlsDetector/multiSlsDetector.cpp | 13 ++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/slsDetectorSoftware/commonFiles/error_defs.h b/slsDetectorSoftware/commonFiles/error_defs.h index 55c84218a..1db390581 100644 --- a/slsDetectorSoftware/commonFiles/error_defs.h +++ b/slsDetectorSoftware/commonFiles/error_defs.h @@ -14,12 +14,17 @@ using namespace std; #include "sls_detector_defs.h" - +#include +#include /** Error flags */ +/*Assumption: Only upto 63 detectors */ #define CRITICAL_ERROR_MASK 0xFFFFFFFF +#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL + + #define CANNOT_CONNECT_TO_DETECTOR 0x8000000000000000ULL #define CANNOT_CONNECT_TO_RECEIVER 0x4000000000000000ULL #define COULDNOT_SET_CONTROL_PORT 0x2000000000000000ULL @@ -73,7 +78,9 @@ class errorDefs { public: /** Constructor */ - errorDefs():errorMask(0){}; + errorDefs():errorMask(0){ + strcpy(notAddedList,""); + }; /** Gets the error message * param errorMask error mask @@ -234,12 +241,31 @@ public: */ int64_t clearErrorMask(){errorMask=0;return errorMask;}; + /** Gets the not added detector list + /returns list + */ + char* getNotAddedList(){return notAddedList;}; + + /** Append the detector to not added detector list + * @param name append to the list + /returns list + */ + void appendNotAddedList(const char* name){strcat(notAddedList,name);strcat(notAddedList,"+");}; + + /** Clears not added detector list + /returns error mask + */ + void clearNotAddedList(){strcpy(notAddedList,"");}; + protected: /** Error Mask */ int64_t errorMask; + /** Detectors Not added List */ + char notAddedList[MAX_STR_LENGTH]; + }; #endif /* ERROR_DEFS_H_ */ diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 5023cb175..17a09f232 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -655,7 +655,6 @@ int multiSlsDetector::setDetectorId(int ival, int pos){ int multiSlsDetector::addSlsDetector(const char *name, int pos) { - detectorType t=getDetectorType(string(name)); int online=0; slsDetector *s=NULL; @@ -695,6 +694,8 @@ int multiSlsDetector::addSlsDetector(const char *name, int pos) { t=slsDetector::getDetectorType(name, DEFAULT_PORTNO); if (t==GENERIC) { cout << "Detector " << name << "does not exist in shared memory and could not connect to it to determine the type (which is not specified)!" << endl; + setErrorMask(getErrorMask()|MULTI_DETECTORS_NOT_ADDED); + appendNotAddedList(name); return -1; } #ifdef VERBOSE @@ -4367,8 +4368,12 @@ int multiSlsDetector::readConfigurationFile(string const fname){ setNumberOfModules(-1); getMaxNumberOfModules(); - if (getErrorMask()) + if (getErrorMask()){ + int c; + cprintf(RED,"\n----------------\n Error Messages\n----------------\n%s\n", + getErrorMessage(c).c_str()); return FAIL; + } return OK; @@ -5472,6 +5477,9 @@ string multiSlsDetector::getErrorMessage(int &critical){ multiMask = getErrorMask(); if(multiMask){ + if(multiMask & MULTI_DETECTORS_NOT_ADDED) + retval.append("Detectors not added:\n"+string(getNotAddedList())+string("\n")); + for (int idet=0; idetnumberOfDetectors; idet++) { if (detectors[idet]) { //if the detector has error @@ -5502,6 +5510,7 @@ string multiSlsDetector::getErrorMessage(int &critical){ int64_t multiSlsDetector::clearAllErrorMask(){ clearErrorMask(); + clearNotAddedList(); for (int idet=0; idetnumberOfDetectors; idet++) if (detectors[idet]) detectors[idet]->clearErrorMask();