client multi.cpp some more changes

This commit is contained in:
maliakal_d 2018-10-03 12:53:50 +02:00
parent a1b24a637b
commit 6bfc212f19

View File

@ -341,7 +341,7 @@ std::string multiSlsDetector::getErrorMessage(int& critical, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
if(isDetectorIndexOutOfBounds()) if(isDetectorIndexOutOfBounds(detPos))
return retval; return retval;
slsMask = getErrorMask(); slsMask = getErrorMask();
@ -367,7 +367,7 @@ std::string multiSlsDetector::getErrorMessage(int& critical, int detPos) {
} }
if (multiMask & MULTI_POS_EXCEEDS_LIST) { if (multiMask & MULTI_POS_EXCEEDS_LIST) {
retval.append("Position exceeds multi detector list\n"); retval.append("Position exceeds multi detector list\n");
critical = 1; critical = 0;
} }
@ -403,7 +403,7 @@ int64_t multiSlsDetector::clearAllErrorMask(int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
if(isDetectorIndexOutOfBounds()) if(isDetectorIndexOutOfBounds(detPos))
return -1; return -1;
return detectors[idet]->clearErrorMask(); return detectors[idet]->clearErrorMask();
} }
@ -449,7 +449,7 @@ int multiSlsDetector::checkVersionCompatibility(portType t, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
if(isDetectorIndexOutOfBounds()) if(isDetectorIndexOutOfBounds(detPos))
return -1; return -1;
int ret = detectors[detPos]->checkVersionCompatibility(t); int ret = detectors[detPos]->checkVersionCompatibility(t);
@ -467,7 +467,7 @@ int64_t multiSlsDetector::getId(idMode mode, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
if(isDetectorIndexOutOfBounds()) if(isDetectorIndexOutOfBounds(detPos))
return -1; return -1;
int64_t ret = detectors[detPos]->getId(mode); int64_t ret = detectors[detPos]->getId(mode);
@ -481,21 +481,52 @@ int64_t multiSlsDetector::getId(idMode mode, int detPos) {
} }
slsDetector* multiSlsDetector::getSlsDetector(unsigned int pos) { slsDetector* multiSlsDetector::getSlsDetector(int detPos) {
if (pos >= 0 && pos < detectors.size()) {
// single
if (detPos >= 0) {
if(isDetectorIndexOutOfBounds(detPos))
return 0;
return detectors[pos]; return detectors[pos];
} }
//multi
return 0; return 0;
} }
slsDetector *multiSlsDetector::operator()(int pos) const { slsDetector *multiSlsDetector::operator()(int detPos) const {
if (pos >= 0 && pos < (int)detectors.size())
// single
if (detPos >= 0) {
if(isDetectorIndexOutOfBounds(detPos))
return NULL;
return detectors[pos]; return detectors[pos];
}
//multi
return NULL; return NULL;
} }
void multiSlsDetector::freeSharedMemory(int multiId) { void multiSlsDetector::freeSharedMemory(int multiId, int detPos) {
// single
if (detPos >= 0) {
if(isDetectorIndexOutOfBounds(detPos))
return NULL;
detectors[detPos]->freeSharedMemory(multiId, detPos);
if (detectors[detPos]->getErrorMask())
setErrorMask(getErrorMask() | (1 << detPos));
return;
}
// multi
// get number of detectors // get number of detectors
int numDetectors = 0; int numDetectors = 0;
SharedMemory* shm = new SharedMemory(multiId, -1); SharedMemory* shm = new SharedMemory(multiId, -1);
@ -520,6 +551,20 @@ void multiSlsDetector::freeSharedMemory(int multiId) {
void multiSlsDetector::freeSharedMemory() { void multiSlsDetector::freeSharedMemory() {
// single
if (detPos >= 0) {
if(isDetectorIndexOutOfBounds(detPos))
return NULL;
detectors[detPos]->freeSharedMemory();
if (detectors[detPos]->getErrorMask())
setErrorMask(getErrorMask() | (1 << detPos));
return;
}
// multi
// clear zmq vector // clear zmq vector
for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) { for (std::vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
delete(*it); delete(*it);
@ -4602,7 +4647,7 @@ int multiSlsDetector::kbhit() {
bool multiSlsDetector::isDetectorIndexOutOfBounds(int detPos) { bool multiSlsDetector::isDetectorIndexOutOfBounds(int detPos) {
// position exceeds multi list size // position exceeds multi list size
if (detPos >= detectors.size()) { if (detPos >= (int)detectors.size()) {
FILE_LOG(logERROR) << "Position " << detPos << " is out of bounds with a detector list of " << detectors.size(); FILE_LOG(logERROR) << "Position " << detPos << " is out of bounds with a detector list of " << detectors.size();
setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST); setErrorMask(getErrorMask() | MULTI_POS_EXCEEDS_LIST);
return true; return true;