mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
parallelized set timer, file index
This commit is contained in:
parent
e6125c3c7f
commit
54d231d3c6
@ -1948,33 +1948,50 @@ void multiSlsDetector::resetFinalDataQueue() {
|
||||
CYCLES_NUMBER,
|
||||
GATE_INTEGRATED_TIME
|
||||
}
|
||||
*/
|
||||
*/
|
||||
int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){
|
||||
int i;
|
||||
int64_t ret1=-100, ret;
|
||||
|
||||
int ret=-100;
|
||||
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return -1;
|
||||
}else{
|
||||
//return storage values
|
||||
int64_t* iret[thisMultiDetector->numberOfDetectors];
|
||||
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new int64_t(-1);
|
||||
Task* task = new Task(new func2_t<int64_t,timerIndex,int64_t>(&slsDetector::setTimer,
|
||||
detectors[idet],index,t,iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++){
|
||||
if(detectors[idet]){
|
||||
if(iret[idet] != NULL){
|
||||
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<<idet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (index==SAMPLES_JCTB)
|
||||
setDynamicRange();
|
||||
|
||||
thisMultiDetector->timerValue[index]=ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (i=0; i<thisMultiDetector->numberOfDetectors; i++) {
|
||||
if (detectors[i]) {
|
||||
ret=detectors[i]->setTimer(index,t);
|
||||
if(detectors[i]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<i));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1)
|
||||
ret1=-1;
|
||||
|
||||
}
|
||||
}
|
||||
if (index==SAMPLES_JCTB)
|
||||
setDynamicRange();
|
||||
// check return values!!!
|
||||
|
||||
thisMultiDetector->timerValue[index]=ret1;
|
||||
|
||||
return ret1;
|
||||
};
|
||||
|
||||
|
||||
int64_t multiSlsDetector::getTimeLeft(timerIndex index){
|
||||
@ -5142,20 +5159,41 @@ slsReceiverDefs::fileFormat multiSlsDetector::setFileFormat(fileFormat f) {
|
||||
|
||||
|
||||
int multiSlsDetector::setFileIndex(int i) {
|
||||
int ret=-100, ret1;
|
||||
|
||||
for (int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++) {
|
||||
if (detectors[idet]) {
|
||||
ret1=detectors[idet]->setFileIndex(i);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret==-100)
|
||||
ret=ret1;
|
||||
else if (ret!=ret1)
|
||||
ret=-1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
int ret=-100;
|
||||
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return -1;
|
||||
}else{
|
||||
//return storage values
|
||||
int* iret[thisMultiDetector->numberOfDetectors];
|
||||
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new int(-1);
|
||||
Task* task = new Task(new func1_t<int,int>(&slsDetector::setFileIndex,
|
||||
detectors[idet],i,iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
for(int idet=0; idet<thisMultiDetector->numberOfDetectors; idet++){
|
||||
if(detectors[idet]){
|
||||
if(iret[idet] != NULL){
|
||||
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<<idet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,7 +108,8 @@ private:
|
||||
|
||||
class SuperTask: public virtual slsDetectorDefs {
|
||||
public:
|
||||
SuperTask():m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0){};
|
||||
SuperTask():
|
||||
m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
|
||||
~SuperTask(){};
|
||||
protected:
|
||||
/** Function signature defined
|
||||
@ -123,11 +124,12 @@ protected:
|
||||
func2_t <int, string,int>* m7;
|
||||
func2_t <dacs_t, dacIndex,int>* m8;
|
||||
func2_t <detectorSettings, detectorSettings,int>* m9;
|
||||
func2_t <string, networkParameter,string>* m10;
|
||||
func3_t <int, int,int,int>* m11;
|
||||
func4_t <int, trimMode,int,int,int>* m12;
|
||||
func4_t <int, int,int,detectorSettings,int>* m13;
|
||||
func4_t <dacs_t, dacs_t,dacIndex,int,int>* m14;
|
||||
func2_t <int64_t, timerIndex,int64_t>* m10;
|
||||
func2_t <string, networkParameter,string>* m11;
|
||||
func3_t <int, int,int,int>* m12;
|
||||
func4_t <int, trimMode,int,int,int>* m13;
|
||||
func4_t <int, int,int,detectorSettings,int>* m14;
|
||||
func4_t <dacs_t, dacs_t,dacIndex,int,int>* m15;
|
||||
};
|
||||
|
||||
class Task: public virtual SuperTask {
|
||||
@ -144,11 +146,12 @@ public:
|
||||
Task(func2_t <int, string,int>* t): SuperTask(),fnum(7){m7 = t;};
|
||||
Task(func2_t <dacs_t, dacIndex,int>* t): SuperTask(),fnum(8){m8 = t;};
|
||||
Task(func2_t <detectorSettings, detectorSettings,int>* t): SuperTask(),fnum(9){m9 = t;};
|
||||
Task(func2_t <string, networkParameter,string>* t): SuperTask(),fnum(10){m10 = t;};
|
||||
Task(func3_t <int, int,int,int>* t): SuperTask(),fnum(11){m11 = t;};
|
||||
Task(func4_t <int, trimMode,int,int,int>* t): SuperTask(),fnum(12){m12 = t;};
|
||||
Task(func4_t <int, int,int,detectorSettings,int>* t): SuperTask(),fnum(13){m13 = t;};
|
||||
Task(func4_t <dacs_t, dacs_t,dacIndex,int,int>* t): SuperTask(),fnum(14){m14 = t;};
|
||||
Task(func2_t <int64_t, timerIndex,int64_t>* t): SuperTask(),fnum(10){m10 = t;};
|
||||
Task(func2_t <string, networkParameter,string>* t): SuperTask(),fnum(11){m11 = t;};
|
||||
Task(func3_t <int, int,int,int>* t): SuperTask(),fnum(12){m12 = t;};
|
||||
Task(func4_t <int, trimMode,int,int,int>* t): SuperTask(),fnum(13){m13 = t;};
|
||||
Task(func4_t <int, int,int,detectorSettings,int>* t): SuperTask(),fnum(14){m14 = t;};
|
||||
Task(func4_t <dacs_t, dacs_t,dacIndex,int,int>* t): SuperTask(),fnum(15){m15 = t;};
|
||||
|
||||
~Task(){}
|
||||
|
||||
@ -168,6 +171,7 @@ public:
|
||||
case 12: (*m12)(); break;
|
||||
case 13: (*m13)(); break;
|
||||
case 14: (*m14)(); break;
|
||||
case 15: (*m15)(); break;
|
||||
default:
|
||||
cprintf(RED, "Error: Task not defined. Abort!\n");
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user