mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 00:00:02 +02:00
parallelizing adcs and dacs
This commit is contained in:
parent
57ae305c7d
commit
1ed4407c11
@ -2970,53 +2970,86 @@ int multiSlsDetector::getAngularConversion(int &direction, angleConversionCons
|
||||
|
||||
|
||||
dacs_t multiSlsDetector::setDAC(dacs_t val, dacIndex idac, int mV, int imod) {
|
||||
dacs_t ret, ret1=-100;
|
||||
|
||||
int id=-1, im=-1;
|
||||
int dmi=0, dma=thisMultiDetector->numberOfDetectors;
|
||||
|
||||
if (decodeNMod(imod, id, im)>=0) {
|
||||
dmi=id;
|
||||
dma=dma+1;
|
||||
}
|
||||
dacs_t ret = -100;
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return -1;
|
||||
}else{
|
||||
int id=-1, im=-1;
|
||||
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
|
||||
if (decodeNMod(imod, id, im)>=0) {
|
||||
posmin=id;
|
||||
posmax=id+1;
|
||||
}
|
||||
|
||||
for (int idet=dmi; idet<dma; idet++) {
|
||||
if (detectors[idet]) {
|
||||
ret=detectors[idet]->setDAC(val, idac, mV, im);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1)
|
||||
ret1=-1;
|
||||
}
|
||||
}
|
||||
return ret1;
|
||||
//return storage values
|
||||
dacs_t* iret[posmax-posmin];
|
||||
for(int idet=posmin; idet<posmax; ++idet){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new dacs_t(-1);
|
||||
Task* task = new Task(new func4_t <dacs_t,slsDetector,dacs_t,dacIndex,int,int,dacs_t>(&slsDetector::setDAC,
|
||||
detectors[idet],val, idac, mV, im, iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
for(int idet=posmin; idet<posmax; 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;
|
||||
}
|
||||
|
||||
dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) {
|
||||
dacs_t ret, ret1=-100;
|
||||
|
||||
int id=-1, im=-1;
|
||||
int dmi=0, dma=thisMultiDetector->numberOfDetectors;
|
||||
|
||||
if (decodeNMod(imod, id, im)>=0) {
|
||||
dmi=id;
|
||||
dma=dma+1;
|
||||
}
|
||||
|
||||
for (int idet=dmi; idet<dma; idet++) {
|
||||
if (detectors[idet]) {
|
||||
ret=detectors[idet]->getADC(idac, im);
|
||||
if(detectors[idet]->getErrorMask())
|
||||
setErrorMask(getErrorMask()|(1<<idet));
|
||||
if (ret1==-100)
|
||||
ret1=ret;
|
||||
else if (ret!=ret1)
|
||||
ret1=-1;
|
||||
}
|
||||
}
|
||||
return ret1;
|
||||
dacs_t ret = -100;
|
||||
if(!threadpool){
|
||||
cout << "Error in creating threadpool. Exiting" << endl;
|
||||
return -1;
|
||||
}else{
|
||||
int id=-1, im=-1;
|
||||
int posmin=0, posmax=thisMultiDetector->numberOfDetectors;
|
||||
if (decodeNMod(imod, id, im)>=0) {
|
||||
posmin=id;
|
||||
posmax=id+1;
|
||||
}
|
||||
//return storage values
|
||||
dacs_t* iret[posmax-posmin];
|
||||
for(int idet=posmin; idet<posmax; ++idet){
|
||||
if(detectors[idet]){
|
||||
iret[idet]= new dacs_t(-1);
|
||||
Task* task = new Task(new func2_t <dacs_t,slsDetector,dacIndex,int,dacs_t>(&slsDetector::getADC,
|
||||
detectors[idet],idac, im, iret[idet]));
|
||||
threadpool->add_task(task);
|
||||
}
|
||||
}
|
||||
threadpool->startExecuting();
|
||||
threadpool->wait_for_tasks_to_complete();
|
||||
for(int idet=posmin; idet<posmax; 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;
|
||||
}
|
||||
|
||||
int multiSlsDetector::setChannel(int64_t reg, int ichan, int ichip, int imod) {
|
||||
|
@ -930,7 +930,7 @@ class multiSlsDetector : public slsDetectorUtils {
|
||||
\param imod module number (if -1 alla modules)
|
||||
\returns current DAC value
|
||||
*/
|
||||
dacs_t getADC(dacIndex index, int imod=0);
|
||||
dacs_t getADC(dacIndex index, int imod=-1);
|
||||
/**
|
||||
configure channel
|
||||
\param reg channel register
|
||||
|
@ -106,31 +106,36 @@ private:
|
||||
class Task: public virtual slsDetectorDefs{
|
||||
public:
|
||||
/* Return: int, Param: int */
|
||||
Task(func1_t <int,slsDetector,int,int>* t): m1(t),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
Task(func1_t <int,slsDetector,int,int>* t): m1(t),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){};
|
||||
/* Return: int, Param: string,int */
|
||||
Task(func2_t <int,slsDetector,string,int,int>* t): m1(0),m2(t),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
Task(func2_t <int,slsDetector,string,int,int>* t): m1(0),m2(t),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){};
|
||||
/* Return: string, Param: string */
|
||||
Task(func1_t <string,slsDetector,string,string>* t): m1(0),m2(0),m3(t),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
Task(func1_t <string,slsDetector,string,string>* t): m1(0),m2(0),m3(t),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
|
||||
/* Return: char*, Param: char* */
|
||||
Task(func1_t <char*,slsDetector,char*,string>* t): m1(0),m2(0),m3(0),m4(t),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
Task(func1_t <char*,slsDetector,char*,string>* t): m1(0),m2(0),m3(0),m4(t),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
|
||||
/* Return: detectorSettings, Param: int */
|
||||
Task(func1_t <detectorSettings,slsDetector,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(t),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
Task(func1_t <detectorSettings,slsDetector,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(t),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
|
||||
/* Return: detectorSettings, Param: detectorSettings,int */
|
||||
Task(func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(t),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
Task(func2_t <detectorSettings,slsDetector,detectorSettings,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(t),m7(0),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
|
||||
/* Return: int, Param: int,int */
|
||||
Task(func2_t <int,slsDetector,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(t),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
Task(func2_t <int,slsDetector,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(t),m8(0),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
|
||||
/* Return: int, Param: int,int,int */
|
||||
Task(func3_t <int,slsDetector,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(t),m9(0),m10(0),m11(0),m12(0),m13(0){};
|
||||
Task(func3_t <int,slsDetector,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(t),m9(0),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
|
||||
/* Return: int, Param: trimMode,int,int,int */
|
||||
Task(func4_t <int,slsDetector,trimMode,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(t),m10(0),m11(0),m12(0),m13(0){};
|
||||
Task(func4_t <int,slsDetector,trimMode,int,int,int,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(t),m10(0),m11(0),m12(0),m13(0),m14(0),m15(0){};
|
||||
/* Return: int, Param: none */
|
||||
Task(func0_t <int,slsDetector,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(t),m11(0),m12(0),m13(0){};
|
||||
Task(func0_t <int,slsDetector,int>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(t),m11(0),m12(0),m13(0),m14(0),m15(0){};
|
||||
/* Return: char*, Param: networkParameter,string */
|
||||
Task(func2_t <string,slsDetector,networkParameter,string,string>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(t),m12(0),m13(0){};
|
||||
Task(func2_t <string,slsDetector,networkParameter,string,string>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(t),m12(0),m13(0),m14(0),m15(0){};
|
||||
/* Return: void, Param: none */
|
||||
Task(func00_t <void,slsDetector>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(t),m13(0){};
|
||||
Task(func00_t <void,slsDetector>* t): m1(0),m2(0),m3(0),m4(0),m5(0),m6(0),m7(0),m8(0),m9(0),m10(0),m11(0),m12(t),m13(0),m14(0),m15(0){};
|
||||
/* Return: int, Param: int,int,detectorSettings */
|
||||
Task(func3_t <int,slsDetector,int,int,detectorSettings,int>* t): 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(t){};
|
||||
Task(func3_t <int,slsDetector,int,int,detectorSettings,int>* t): 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(t),m14(0),m15(0){};
|
||||
/* Return: dacs_t, Param: dacs_t, dacIndex, int, int */
|
||||
Task(func4_t <dacs_t,slsDetector,dacs_t,dacIndex,int,int,dacs_t>* t): 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(t),m15(0){};
|
||||
/* Return: dacs_t, Param: dacIndex, int */
|
||||
Task(func2_t <dacs_t,slsDetector,dacIndex,int,dacs_t>* t): 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(t){};
|
||||
|
||||
|
||||
|
||||
|
||||
@ -150,6 +155,9 @@ public:
|
||||
else if(m11) (*m11)();
|
||||
else if(m12) (*m12)();
|
||||
else if(m13) (*m13)();
|
||||
else if(m14) (*m14)();
|
||||
else if(m15) (*m15)();
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
@ -179,6 +187,11 @@ private:
|
||||
func00_t <void,slsDetector>* m12;
|
||||
/* Return: int, Param: int,int,detectorSettings */
|
||||
func3_t <int,slsDetector,int,int,detectorSettings,int>* m13;
|
||||
/* Return: dacs_t, Param: dacs_t, dacIndex, int, int */
|
||||
func4_t <dacs_t,slsDetector,dacs_t,dacIndex,int,int,dacs_t>* m14;
|
||||
/* Return: dacs_t, Param: dacIndex, int */
|
||||
func2_t <dacs_t,slsDetector,dacIndex,int,dacs_t>* m15;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user