diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 0c5c3fbe1..8b55a0646 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -4228,40 +4228,59 @@ int multiSlsDetector::setCounterBit(int i){ int multiSlsDetector::setDynamicRange(int p) { - int ret=-100, ret1; - thisMultiDetector->dataBytes=0; - thisMultiDetector->numberOfChannels=0; - - for (int idet=0; idetnumberOfDetectors; ++idet) { - if (detectors[idet]) { - ret1=detectors[idet]->setDynamicRange(p); - if(detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask()|(1<dataBytes+=detectors[idet]->getDataBytes(); - // cout << "db " << idet << " " << detectors[idet]->getDataBytes() << endl; - thisMultiDetector->numberOfChannels+=detectors[idet]->getTotalNumberOfChannels(); - if (ret==-100) - ret=ret1; - else if (ret!=ret1) - ret=-1; - } - } - - //for usability for the user - if (getDetectorsType() == EIGER){ - if(p == 32){ - std::cout << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32" << std::endl; - setSpeed(CLOCK_DIVIDER,2); - } - else if(p == 16){ - std::cout << "Setting Clock to Half Speed for Dynamic Range of 16" << std::endl; - setSpeed(CLOCK_DIVIDER,1); - } - } - return ret; + int ret=-100; + thisMultiDetector->dataBytes=0; + thisMultiDetector->numberOfChannels=0; + if(!threadpool){ + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + }else{ + //return storage values + int* iret[thisMultiDetector->numberOfDetectors]; + for(int idet=0; idetnumberOfDetectors; ++idet){ + if(detectors[idet]){ + iret[idet]= new int(-1); + Task* task = new Task(new func1_t(&slsDetector::setDynamicRange, + detectors[idet],p,iret[idet])); + threadpool->add_task(task); + } + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for(int idet=0; idetnumberOfDetectors; ++idet){ + if(detectors[idet]){ + if(iret[idet] != NULL){ + thisMultiDetector->dataBytes+=detectors[idet]->getDataBytes(); + thisMultiDetector->numberOfChannels+=detectors[idet]->getTotalNumberOfChannels(); + if (ret==-100) + ret=*iret[idet]; + else if (ret!=*iret[idet]) + ret=-1; + delete iret[idet]; + }else ret=-1; + if(detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask()|(1<