diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index f229c588f..c947ecc10 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -2828,41 +2828,74 @@ int multiSlsDetector::setRateCorrection(double t){ #ifdef VERBOSE std::cout<< "Setting rate correction with dead time "<< thisMultiDetector->tDead << std::endl; #endif + int ret=OK; + int posmax=thisMultiDetector->numberOfDetectors; + // eiger return value is ok/fail if (getDetectorsType() == EIGER){ - int ret = OK, ret1= OK; - for (int idet=0; idetnumberOfDetectors; ++idet) { - if (detectors[idet]) { - ret=detectors[idet]->setRateCorrection(t); - if(detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask()|(1<(&slsDetector::setRateCorrection, + detectors[idet],t,iret[idet])); + threadpool->add_task(task); + } + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for(int idet=0; idetgetErrorMask()) + setErrorMask(getErrorMask()|(1<correctionMask&=~(1<correctionMask&(1<correctionMask|=(1<numberOfDetectors; ++idet) { - if (detectors[idet]) { - ret=detectors[idet]->setRateCorrection(t); - if(detectors[idet]->getErrorMask()) - setErrorMask(getErrorMask()|(1<(&slsDetector::setRateCorrection, + detectors[idet],t,iret[idet])); + threadpool->add_task(task); + } + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + for(int idet=0; idetgetErrorMask()) + setErrorMask(getErrorMask()|(1<correctionMask&(1<numberOfDetectors; ++idet) { - if (detectors[idet]) { - ret=detectors[idet]->getRateCorrectionTau(); - if (ret1==-100) - ret1=ret; - else if (ret!=ret1){ - std::cout<< "Rate correction is different for different readouts " << std::endl; - ret1=-1; + double ret=-100.0; + int posmax = thisMultiDetector->numberOfDetectors; + + if(!threadpool){ + cout << "Error in creating threadpool. Exiting" << endl; + return -1; + }else{ + double* iret[posmax]; + for(int idet=0; idetnumberOfDetectors; ++idet){ + if(detectors[idet]){ + iret[idet]= new double(-1); + Task* task = new Task(new func0_t(&slsDetector::getRateCorrectionTau, + detectors[idet],iret[idet])); + threadpool->add_task(task); + } + } + threadpool->startExecuting(); + threadpool->wait_for_tasks_to_complete(); + + for(int idet=0; idet 0.000000001) { + std::cout<< "Rate correction is different for different readouts " << std::endl; + ret=-1; + } + delete iret[idet]; + }else ret = -1; + if(detectors[idet]->getErrorMask()) + setErrorMask(getErrorMask()|(1<* m1; func0_t * m2; - func0_t * m3; - func1_t * m4; - func1_t * m5; - func1_t * m6; - func2_t * m7; - func2_t * m8; - func2_t * m9; - func2_t * m10; - func2_t * m11; - func2_t * m12; - func3_t * m13; - func4_t * m14; - func4_t * m15; - func4_t * m16; + func0_t * m3; + func0_t * m4; + func1_t * m5; + func1_t * m6; + func1_t * m7; + func1_t * m8; + func2_t * m9; + func2_t * m10; + func2_t * m11; + func2_t * m12; + func2_t * m13; + func2_t * m14; + func3_t * m15; + func4_t * m16; + func4_t * m17; + func4_t * m18; }; class Task: public virtual SuperTask { @@ -140,20 +142,22 @@ public: */ Task(func00_t * t): SuperTask(),fnum(1){m1 = t;}; Task(func0_t * t): SuperTask(),fnum(2){m2 = t;}; - Task(func0_t * t): SuperTask(),fnum(3){m3 = t;}; - Task(func1_t * t): SuperTask(),fnum(4){m4 = t;}; - Task(func1_t * t): SuperTask(),fnum(5){m5 = t;}; - Task(func1_t * t): SuperTask(),fnum(6){m6 = t;}; - Task(func2_t * t): SuperTask(),fnum(7){m7 = t;}; - Task(func2_t * t): SuperTask(),fnum(8){m8 = t;}; - Task(func2_t * t): SuperTask(),fnum(9){m9 = t;}; - Task(func2_t * t): SuperTask(),fnum(10){m10 = t;}; - Task(func2_t * t): SuperTask(),fnum(11){m11 = t;}; - Task(func2_t * t): SuperTask(),fnum(12){m12 = t;}; - Task(func3_t * t): SuperTask(),fnum(13){m13 = t;}; - Task(func4_t * t): SuperTask(),fnum(14){m14 = t;}; - Task(func4_t * t): SuperTask(),fnum(15){m15 = t;}; - Task(func4_t * t): SuperTask(),fnum(16){m16 = t;}; + Task(func0_t * t): SuperTask(),fnum(3){m3 = t;}; + Task(func0_t * t): SuperTask(),fnum(4){m4 = t;}; + Task(func1_t * t): SuperTask(),fnum(5){m5 = t;}; + Task(func1_t * t): SuperTask(),fnum(6){m6 = t;}; + Task(func1_t * t): SuperTask(),fnum(7){m7 = t;}; + Task(func1_t * t): SuperTask(),fnum(8){m8 = t;}; + Task(func2_t * t): SuperTask(),fnum(9){m9 = t;}; + Task(func2_t * t): SuperTask(),fnum(10){m10 = t;}; + Task(func2_t * t): SuperTask(),fnum(11){m11 = t;}; + Task(func2_t * t): SuperTask(),fnum(12){m12 = t;}; + Task(func2_t * t): SuperTask(),fnum(13){m13 = t;}; + Task(func2_t * t): SuperTask(),fnum(14){m14 = t;}; + Task(func3_t * t): SuperTask(),fnum(15){m15 = t;}; + Task(func4_t * t): SuperTask(),fnum(16){m16 = t;}; + Task(func4_t * t): SuperTask(),fnum(17){m17 = t;}; + Task(func4_t * t): SuperTask(),fnum(18){m18 = t;}; ~Task(){} @@ -175,6 +179,8 @@ public: case 14: (*m14)(); break; case 15: (*m15)(); break; case 16: (*m16)(); break; + case 17: (*m17)(); break; + case 18: (*m18)(); break; default: cprintf(RED, "Error: Task not defined. Abort!\n"); break;