mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 15:57:13 +02:00
client multi.cpp modified common out of bounds error
This commit is contained in:
@ -25,6 +25,7 @@
|
|||||||
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
|
#define MULTI_DETECTORS_NOT_ADDED 0x8000000000000000ULL
|
||||||
#define MULTI_HAVE_DIFFERENT_VALUES 0x4000000000000000ULL
|
#define MULTI_HAVE_DIFFERENT_VALUES 0x4000000000000000ULL
|
||||||
#define MULTI_CONFIG_FILE_ERROR 0x2000000000000000ULL
|
#define MULTI_CONFIG_FILE_ERROR 0x2000000000000000ULL
|
||||||
|
#define MULTI_POS_EXCEEDS_LIST 0x1000000000000000ULL
|
||||||
|
|
||||||
// sls errors
|
// sls errors
|
||||||
#define CRITICAL_ERROR_MASK 0xFFFFFFF
|
#define CRITICAL_ERROR_MASK 0xFFFFFFF
|
||||||
|
@ -340,11 +340,10 @@ std::string multiSlsDetector::getErrorMessage(int& critical, int detPos) {
|
|||||||
|
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
// position exceeds multi list size
|
|
||||||
if (detPos > detectors.size()) {
|
if(isDetectorIndexOutOfBounds())
|
||||||
FILE_LOG(logERROR) << "Position " << detPos << " exceeds list of " << detectors.size();
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
|
||||||
slsMask = getErrorMask();
|
slsMask = getErrorMask();
|
||||||
posmin = (unsigned int)detPos;
|
posmin = (unsigned int)detPos;
|
||||||
posmax = posmin + 1;
|
posmax = posmin + 1;
|
||||||
@ -404,14 +403,8 @@ int64_t multiSlsDetector::clearAllErrorMask(int detPos) {
|
|||||||
|
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
|
if(isDetectorIndexOutOfBounds())
|
||||||
// position exceeds multi list size
|
|
||||||
if (detPos > detectors.size()) {
|
|
||||||
FILE_LOG(logERROR) << "Position " << detPos << " exceeds list of " << detectors.size();
|
|
||||||
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
return detectors[idet]->clearErrorMask();
|
return detectors[idet]->clearErrorMask();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,12 +449,8 @@ int multiSlsDetector::checkVersionCompatibility(portType t, int detPos) {
|
|||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
|
|
||||||
// position exceeds multi list size
|
if(isDetectorIndexOutOfBounds())
|
||||||
if (detPos > detectors.size()) {
|
|
||||||
FILE_LOG(logERROR) << "Position " << detPos << " exceeds list of " << detectors.size();
|
|
||||||
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
int ret = detectors[detPos]->checkVersionCompatibility(t);
|
int ret = detectors[detPos]->checkVersionCompatibility(t);
|
||||||
if (detectors[detPos]->getErrorMask())
|
if (detectors[detPos]->getErrorMask())
|
||||||
@ -478,12 +467,8 @@ int64_t multiSlsDetector::getId(idMode mode, int detPos) {
|
|||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
|
|
||||||
// position exceeds multi list size
|
if(isDetectorIndexOutOfBounds())
|
||||||
if (detPos > detectors.size()) {
|
|
||||||
FILE_LOG(logERROR) << "Position " << detPos << " exceeds list of " << detectors.size();
|
|
||||||
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
int64_t ret = detectors[detPos]->getId(mode);
|
int64_t ret = detectors[detPos]->getId(mode);
|
||||||
if (detectors[detPos]->getErrorMask())
|
if (detectors[detPos]->getErrorMask())
|
||||||
@ -4614,3 +4599,13 @@ int multiSlsDetector::kbhit() {
|
|||||||
select(STDIN_FILENO+1, &fds, NULL, NULL, &tv);
|
select(STDIN_FILENO+1, &fds, NULL, NULL, &tv);
|
||||||
return FD_ISSET(STDIN_FILENO, &fds);
|
return FD_ISSET(STDIN_FILENO, &fds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool multiSlsDetector::isDetectorIndexOutOfBounds(int detPos) {
|
||||||
|
// position exceeds multi list size
|
||||||
|
if (detPos >= detectors.size()) {
|
||||||
|
FILE_LOG(logERROR) << "Position " << detPos << " is out of bounds with a detector list of " << detectors.size();
|
||||||
|
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -1569,6 +1569,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
int setThreadedProcessing(int enable=-1);
|
int setThreadedProcessing(int enable=-1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if detector position is out of bounds
|
||||||
|
*/
|
||||||
|
bool isDetectorIndexOutOfBounds(int detPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Initialize (open/create) shared memory for the sharedMultiDetector structure
|
* Initialize (open/create) shared memory for the sharedMultiDetector structure
|
||||||
|
Reference in New Issue
Block a user