diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 3652d3a80..db6a52c2e 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -1190,7 +1190,7 @@ int multiSlsDetector::setThresholdEnergy(int e_eV, int pos, detectorSettings ise for(int idet=posmin; idet(&slsDetector::setThresholdEnergy, + Task* task = new Task(new func4_t(&slsDetector::setThresholdEnergy, detectors[idet],e_eV,-1,isettings,tb,iret[idet])); threadpool->add_task(task); } @@ -1237,11 +1237,11 @@ slsDetectorDefs::detectorSettings multiSlsDetector::getSettings(int pos) { return GET_SETTINGS; }else{ //return storage values - int* iret[posmax-posmin]; + detectorSettings* iret[posmax-posmin]; for(int idet=posmin; idet(&slsDetector::getSettings, + iret[idet]= new detectorSettings(GET_SETTINGS); + Task* task = new Task(new func1_t(&slsDetector::getSettings, detectors[idet],-1,iret[idet])); threadpool->add_task(task); } @@ -1285,11 +1285,11 @@ slsDetectorDefs::detectorSettings multiSlsDetector::setSettings(detectorSettings return GET_SETTINGS; }else{ //return storage values - int* iret[posmax-posmin]; + detectorSettings* iret[posmax-posmin]; for(int idet=posmin; idet(&slsDetector::setSettings, + iret[idet]= new detectorSettings(GET_SETTINGS); + Task* task = new Task(new func2_t(&slsDetector::setSettings, detectors[idet],isettings,-1,iret[idet])); threadpool->add_task(task); } @@ -1374,7 +1374,7 @@ int multiSlsDetector::prepareAcquisition(){ for(int idet=posmin; idetmasterPosition) && (detectors[idet])){ iret[idet]= new int(OK); - Task* task = new Task(new func0_t(&slsDetector::prepareAcquisition, + Task* task = new Task(new func0_t(&slsDetector::prepareAcquisition, detectors[idet],iret[idet])); threadpool->add_task(task); } @@ -1437,7 +1437,7 @@ int multiSlsDetector::cleanupAcquisition(){ for(int idet=posmin; idetmasterPosition) && (detectors[idet])){ iret[idet]= new int(OK); - Task* task = new Task(new func0_t(&slsDetector::cleanupAcquisition, + Task* task = new Task(new func0_t(&slsDetector::cleanupAcquisition, detectors[idet],iret[idet])); threadpool->add_task(task); } @@ -1483,7 +1483,7 @@ int multiSlsDetector::startAcquisition(){ for(int idet=posmin; idetmasterPosition) && (detectors[idet])){ iret[idet]= new int(OK); - Task* task = new Task(new func0_t(&slsDetector::startAcquisition, + Task* task = new Task(new func0_t(&slsDetector::startAcquisition, detectors[idet],iret[idet])); threadpool->add_task(task); } @@ -1545,7 +1545,7 @@ int multiSlsDetector::stopAcquisition(){ for(int idet=posmin; idetmasterPosition) && (detectors[idet])){ iret[idet]= new int(OK); - Task* task = new Task(new func0_t(&slsDetector::stopAcquisition, + Task* task = new Task(new func0_t(&slsDetector::stopAcquisition, detectors[idet],iret[idet])); threadpool->add_task(task); } @@ -1828,7 +1828,7 @@ int multiSlsDetector::startAndReadAllNoWait(){ for(int idet=posmin; idetmasterPosition) && (detectors[idet])){ iret[idet]= new int(OK); - Task* task = new Task(new func0_t(&slsDetector::startAndReadAllNoWait, + Task* task = new Task(new func0_t(&slsDetector::startAndReadAllNoWait, detectors[idet],iret[idet])); threadpool->add_task(task); } @@ -3148,7 +3148,7 @@ dacs_t multiSlsDetector::setDAC(dacs_t val, dacIndex idac, int mV, int imod) { for(int idet=posmin; idet(&slsDetector::setDAC, + Task* task = new Task(new func4_t (&slsDetector::setDAC, detectors[idet],val, idac, mV, imod, iret[idet])); threadpool->add_task(task); } @@ -3210,7 +3210,7 @@ dacs_t multiSlsDetector::getADC(dacIndex idac, int imod) { for(int idet=posmin; idet(&slsDetector::getADC, + Task* task = new Task(new func2_t (&slsDetector::getADC, detectors[idet],idac, imod, iret[idet])); threadpool->add_task(task); } @@ -3608,7 +3608,7 @@ string multiSlsDetector::setNetworkParameter(networkParameter p, string s){ if (p == RECEIVER_STREAMING_PORT) s.append("multi\0"); sret[idet]=new string("error"); - Task* task = new Task(new func2_t (&slsDetector::setNetworkParameter, + Task* task = new Task(new func2_t (&slsDetector::setNetworkParameter, detectors[idet],p,s,sret[idet])); threadpool->add_task(task); } @@ -4264,7 +4264,7 @@ int multiSlsDetector::executeTrimming(trimMode mode, int par1, int par2, int imo for(int idet=0; idetnumberOfDetectors; idet++){ if(detectors[idet]){ iret[idet]= new int(-1); - Task* task = new Task(new func4_t (&slsDetector::executeTrimming, + Task* task = new Task(new func4_t (&slsDetector::executeTrimming, detectors[idet],mode,par1,par2,imod,iret[idet])); threadpool->add_task(task); } @@ -4367,7 +4367,7 @@ int multiSlsDetector::loadSettingsFile(string fname, int imod) { for(int idet=0; idetnumberOfDetectors; idet++){ if(detectors[idet]){ iret[idet]= new int(OK); - Task* task = new Task(new func2_t (&slsDetector::loadSettingsFile, + Task* task = new Task(new func2_t (&slsDetector::loadSettingsFile, detectors[idet],fname,imod,iret[idet])); threadpool->add_task(task); } @@ -4441,7 +4441,7 @@ int multiSlsDetector::setAllTrimbits(int val, int imod){ for(int idet=0; idetnumberOfDetectors; idet++){ if(detectors[idet]){ iret[idet]= new int(-1); - Task* task = new Task(new func2_t (&slsDetector::setAllTrimbits, + Task* task = new Task(new func2_t (&slsDetector::setAllTrimbits, detectors[idet],val,imod,iret[idet])); threadpool->add_task(task); } @@ -4495,7 +4495,7 @@ int multiSlsDetector::loadCalibrationFile(string fname, int imod) { for(int idet=0; idetnumberOfDetectors; idet++){ if(detectors[idet]){ iret[idet]= new int(OK); - Task* task = new Task(new func2_t (&slsDetector::loadCalibrationFile, + Task* task = new Task(new func2_t (&slsDetector::loadCalibrationFile, detectors[idet],fname,imod,iret[idet])); threadpool->add_task(task); } @@ -5173,7 +5173,7 @@ int multiSlsDetector::startReceiver(){ for(int idet=posmin; idetmasterPosition) && (detectors[idet])){ iret[idet]= new int(OK); - Task* task = new Task(new func0_t(&slsDetector::startReceiver, + Task* task = new Task(new func0_t(&slsDetector::startReceiver, detectors[idet],iret[idet])); threadpool->add_task(task); } @@ -5235,7 +5235,7 @@ int multiSlsDetector::stopReceiver(){ for(int idet=posmin; idetmasterPosition) && (detectors[idet])){ iret[idet]= new int(OK); - Task* task = new Task(new func0_t(&slsDetector::stopReceiver, + Task* task = new Task(new func0_t(&slsDetector::stopReceiver, detectors[idet],iret[idet])); threadpool->add_task(task); } @@ -5906,7 +5906,7 @@ int multiSlsDetector::enableDataStreamingFromReceiver(int enable){ for(int idet=0; idetnumberOfDetectors; idet++){ if(detectors[idet]){ iret[idet]= new int(-1); - Task* task = new Task(new func1_t (&slsDetector::enableDataStreamingFromReceiver, + Task* task = new Task(new func1_t (&slsDetector::enableDataStreamingFromReceiver, detectors[idet],enable,iret[idet])); threadpool->add_task(task); } @@ -6135,7 +6135,7 @@ int multiSlsDetector::pulsePixel(int n,int x,int y) { for(int idet=0; idetnumberOfDetectors; idet++){ if(detectors[idet]){ iret[idet]= new int(-1); - Task* task = new Task(new func3_t (&slsDetector::pulsePixel, + Task* task = new Task(new func3_t (&slsDetector::pulsePixel, detectors[idet],n,x,y,iret[idet])); threadpool->add_task(task); } @@ -6172,7 +6172,7 @@ int multiSlsDetector::pulsePixelNMove(int n,int x,int y) { for(int idet=0; idetnumberOfDetectors; idet++){ if(detectors[idet]){ iret[idet]= new int(-1); - Task* task = new Task(new func3_t (&slsDetector::pulsePixelNMove, + Task* task = new Task(new func3_t (&slsDetector::pulsePixelNMove, detectors[idet],n,x,y,iret[idet])); threadpool->add_task(task); } @@ -6209,7 +6209,7 @@ int multiSlsDetector::pulseChip(int n) { for(int idet=0; idetnumberOfDetectors; idet++){ if(detectors[idet]){ iret[idet]= new int(-1); - Task* task = new Task(new func1_t (&slsDetector::pulseChip, + Task* task = new Task(new func1_t (&slsDetector::pulseChip, detectors[idet],n,iret[idet])); threadpool->add_task(task); } diff --git a/slsDetectorSoftware/threadFiles/Task.h b/slsDetectorSoftware/threadFiles/Task.h index 5aff13284..0142f22a2 100644 --- a/slsDetectorSoftware/threadFiles/Task.h +++ b/slsDetectorSoftware/threadFiles/Task.h @@ -16,127 +16,138 @@ using namespace std; class slsDetector; -template +template class func00_t{ public: - func00_t(_Ret (_Class::*fn)(),_Class* ptr): + func00_t(_Ret (slsDetector::*fn)(),slsDetector* ptr): m_fn(fn),m_ptr(ptr){} ~func00_t() {} void operator()() const {((m_ptr->*m_fn)());} private: - _Ret (_Class::*m_fn)(); - _Class* m_ptr; + _Ret (slsDetector::*m_fn)(); + slsDetector* m_ptr; }; -template +template class func0_t{ public: - func0_t(_Ret (_Class::*fn)(),_Class* ptr, _Store* sto): + func0_t(_Ret (slsDetector::*fn)(),slsDetector* ptr, _Ret* sto): m_fn(fn),m_ptr(ptr),m_store(sto){} ~func0_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)());} private: - _Ret (_Class::*m_fn)(); - _Class* m_ptr; - _Store* m_store; + _Ret (slsDetector::*m_fn)(); + slsDetector* m_ptr; + _Ret* m_store; }; -template +template class func1_t{ public: - func1_t(_Ret (_Class::*fn)(_Arg1),_Class* ptr,_Arg1 arg1, _Store* sto): + func1_t(_Ret (slsDetector::*fn)(_Arg1),slsDetector* ptr,_Arg1 arg1, _Ret* sto): m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_store(sto){} ~func1_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1));} private: - _Ret (_Class::*m_fn)(_Arg1); - _Class* m_ptr; + _Ret (slsDetector::*m_fn)(_Arg1); + slsDetector* m_ptr; _Arg1 m_arg1; - _Store* m_store; + _Ret* m_store; }; -template +template class func2_t{ public: - func2_t(_Ret (_Class::*fn)(_Arg1,_Arg2),_Class* ptr,_Arg1 arg1,_Arg2 arg2,_Store* sto): + func2_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Ret* sto): m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_store(sto){} ~func2_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2));} private: - _Ret (_Class::*m_fn)(_Arg1,_Arg2); - _Class* m_ptr; + _Ret (slsDetector::*m_fn)(_Arg1,_Arg2); + slsDetector* m_ptr; _Arg1 m_arg1; _Arg2 m_arg2; - _Store* m_store; + _Ret* m_store; }; -template +template class func3_t{ public: - func3_t(_Ret (_Class::*fn)(_Arg1,_Arg2,_Arg3),_Class* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Store* sto): + func3_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2,_Arg3),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Ret* sto): m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_arg3(arg3),m_store(sto){} ~func3_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3));} private: - _Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3); - _Class* m_ptr; + _Ret (slsDetector::*m_fn)(_Arg1,_Arg2,_Arg3); + slsDetector* m_ptr; _Arg1 m_arg1; _Arg2 m_arg2; _Arg3 m_arg3; - _Store* m_store; + _Ret* m_store; }; -template +template class func4_t{ public: - func4_t(_Ret (_Class::*fn)(_Arg1,_Arg2,_Arg3,_Arg4),_Class* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Arg4 arg4,_Store* sto): + func4_t(_Ret (slsDetector::*fn)(_Arg1,_Arg2,_Arg3,_Arg4),slsDetector* ptr,_Arg1 arg1,_Arg2 arg2,_Arg3 arg3,_Arg4 arg4,_Ret* sto): m_fn(fn),m_ptr(ptr),m_arg1(arg1),m_arg2(arg2),m_arg3(arg3),m_arg4(arg4),m_store(sto){} ~func4_t() {} void operator()() const {*m_store = ((m_ptr->*m_fn)(m_arg1,m_arg2,m_arg3,m_arg4));} private: - _Ret (_Class::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4); - _Class* m_ptr; + _Ret (slsDetector::*m_fn)(_Arg1,_Arg2,_Arg3,_Arg4); + slsDetector* m_ptr; _Arg1 m_arg1; _Arg2 m_arg2; _Arg3 m_arg3; _Arg4 m_arg4; - _Store* m_store; + _Ret* m_store; }; -class Task: public virtual slsDetectorDefs{ + +class SuperTask: public virtual slsDetectorDefs { public: - /* Return: int, Param: int */ - Task(func1_t * 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 * 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 * 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 * 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 * 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 * 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 * 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 * 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 * 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 * 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 * 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 * 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,int */ - Task(func4_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(t),m14(0),m15(0){}; - /* Return: dacs_t, Param: dacs_t, dacIndex, int, int */ - Task(func4_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 * 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){}; + 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){}; +protected: + /** Function defined + * First argument is Return type, the remaining are arguments + */ + func00_t * m1; + func0_t * m2; + func1_t * m3; + func1_t * m4; + func1_t * m5; + func2_t * m6; + func2_t * m7; + func2_t * m8; + func2_t * m9; + func2_t * m10; + func3_t * m11; + func4_t * m12; + func4_t * m13; + func4_t * m14; +}; + +class Task: public virtual SuperTask{ +public: + /** Constructors + * First argument is Return type, the remaining are arguments + */ + Task(func00_t * t): SuperTask(),m1(t){}; + Task(func0_t * 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){}; + Task(func1_t * 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){}; + Task(func1_t * 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){}; + Task(func1_t * 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){}; + Task(func2_t * 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){}; + Task(func2_t * 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){}; + Task(func2_t * 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){}; + Task(func2_t * 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){}; + Task(func2_t * 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){}; + Task(func3_t * 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){}; + Task(func4_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(t),m13(0),m14(0){}; + Task(func4_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(t),m14(0){}; + Task(func4_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){}; ~Task(){} @@ -156,42 +167,7 @@ public: else if(m12) (*m12)(); else if(m13) (*m13)(); else if(m14) (*m14)(); - else if(m15) (*m15)(); - } - -private: - /* Return: int, Param: int */ - func1_t * m1; - /* Return: int, Param: string,int */ - func2_t * m2; - /* Return: string, Param: string */ - func1_t * m3; - /* Return: char*, Param: char* */ - func1_t * m4; - /* Return: detectorSettings, Param: int */ - func1_t * m5; - /* Return: detectorSettings, Param: detectorSettings,int */ - func2_t * m6; - /* Return: int, Param: int,int */ - func2_t * m7; - /* Return: int, Param: int,int,int */ - func3_t * m8; - /* Return: int, Param: trimMode,int,int,int */ - func4_t * m9; - /* Return: int, Param: int */ - func0_t * m10; - /* Return: char*, Param: networkParameter,string */ - func2_t * m11; - /* Return: void, Param: none */ - func00_t * m12; - /* Return: int, Param: int,int,detectorSettings,int */ - func4_t * m13; - /* Return: dacs_t, Param: dacs_t, dacIndex, int, int */ - func4_t * m14; - /* Return: dacs_t, Param: dacIndex, int */ - func2_t * m15; - };