Commit 7153b8a5 authored by Sebastien Petitdemange's avatar Sebastien Petitdemange Committed by Alejandro Homs Puron

Add missing code for roi2spectrum

parent fb51107a
...@@ -59,15 +59,19 @@ sipRes = aReturnListPt; ...@@ -59,15 +59,19 @@ sipRes = aReturnListPt;
SIP_PYOBJECT addOp(SoftOpId,const alias&,int stage); SIP_PYOBJECT addOp(SoftOpId,const alias&,int stage);
%MethodCode %MethodCode
SoftOpInstance anInstance; SoftOpInstance anInstance;
TRY
sipCpp->addOp(a0,*a1,a2,anInstance); sipCpp->addOp(a0,*a1,a2,anInstance);
INSTANCE_2_SoftOp INSTANCE_2_SoftOp
CATCH
%End %End
void delOp(const alias&); void delOp(const alias&);
SIP_PYOBJECT getOpClass(const alias&) const; SIP_PYOBJECT getOpClass(const alias&) const;
%MethodCode %MethodCode
SoftOpInstance anInstance; SoftOpInstance anInstance;
TRY
sipCpp->getOpClass(*a0,anInstance); sipCpp->getOpClass(*a0,anInstance);
INSTANCE_2_SoftOp INSTANCE_2_SoftOp
CATCH
%End %End
void setEndLinkTaskCallback(TaskEventCallback *aCbk); void setEndLinkTaskCallback(TaskEventCallback *aCbk);
...@@ -115,5 +119,17 @@ INSTANCE_2_SoftOp ...@@ -115,5 +119,17 @@ INSTANCE_2_SoftOp
Py_INCREF(Py_None); \ Py_INCREF(Py_None); \
sipRes = Py_None; \ sipRes = Py_None; \
} }
#define TRY try \
{
#define CATCH \
} \
catch(Exception &exp) \
{ \
const std::string& tmpString = exp.getErrMsg(); \
const char *detail = tmpString.c_str(); \
PyErr_SetString(sipException_Exception, detail); \
return NULL; \
}
%End %End
}; };
...@@ -30,6 +30,7 @@ static SoftOpKey SoftOpTable[] = { ...@@ -30,6 +30,7 @@ static SoftOpKey SoftOpTable[] = {
SoftOpKey(FLIP,"Flip"), SoftOpKey(FLIP,"Flip"),
SoftOpKey(MASK,"Mask"), SoftOpKey(MASK,"Mask"),
SoftOpKey(ROICOUNTERS,"Roi counters"), SoftOpKey(ROICOUNTERS,"Roi counters"),
SoftOpKey(ROI2SPECTRUM,"Roi 2 spectrum"),
SoftOpKey(SOFTROI,"Software roi"), SoftOpKey(SOFTROI,"Software roi"),
SoftOpKey(USER_LINK_TASK,"User link task"), SoftOpKey(USER_LINK_TASK,"User link task"),
SoftOpKey(USER_SINK_TASK,"User sink task"), SoftOpKey(USER_SINK_TASK,"User sink task"),
...@@ -136,6 +137,9 @@ void SoftOpExternalMgr::addOp(SoftOpId aSoftOpId, ...@@ -136,6 +137,9 @@ void SoftOpExternalMgr::addOp(SoftOpId aSoftOpId,
newInstance.m_opt = new SoftOpMask(); newInstance.m_opt = new SoftOpMask();
newInstance.m_linkable = true; newInstance.m_linkable = true;
break; break;
case ROI2SPECTRUM:
newInstance.m_opt = new SoftOpRoi2Spectrum();
break;
case SOFTROI: case SOFTROI:
newInstance.m_opt = new SoftOpSoftRoi(); newInstance.m_opt = new SoftOpSoftRoi();
newInstance.m_linkable = true; newInstance.m_linkable = true;
...@@ -148,7 +152,7 @@ void SoftOpExternalMgr::addOp(SoftOpId aSoftOpId, ...@@ -148,7 +152,7 @@ void SoftOpExternalMgr::addOp(SoftOpId aSoftOpId,
newInstance.m_opt = new SoftUserSinkTask(); newInstance.m_opt = new SoftUserSinkTask();
break; break;
default: default:
throw LIMA_CTL_EXC(InvalidValue,"Not yet managed"); THROW_CTL_ERROR(InvalidValue) << "Not yet managed";
} }
std::pair<Stage2Instance::iterator,bool> aResult = std::pair<Stage2Instance::iterator,bool> aResult =
m_stage2instance.insert(std::pair<stage,std::list<SoftOpInstance> >(aStage,std::list<SoftOpInstance>())); m_stage2instance.insert(std::pair<stage,std::list<SoftOpInstance> >(aStage,std::list<SoftOpInstance>()));
...@@ -269,6 +273,7 @@ void SoftOpExternalMgr::_checkIfPossible(SoftOpId aSoftOpId, ...@@ -269,6 +273,7 @@ void SoftOpExternalMgr::_checkIfPossible(SoftOpId aSoftOpId,
case ROICOUNTERS: case ROICOUNTERS:
case BPM: case BPM:
case USER_SINK_TASK: case USER_SINK_TASK:
case ROI2SPECTRUM:
break; // always possible break; // always possible
case BACKGROUNDSUBSTRACTION: case BACKGROUNDSUBSTRACTION:
case BINNING: case BINNING:
...@@ -280,7 +285,7 @@ void SoftOpExternalMgr::_checkIfPossible(SoftOpId aSoftOpId, ...@@ -280,7 +285,7 @@ void SoftOpExternalMgr::_checkIfPossible(SoftOpId aSoftOpId,
checkLinkable = true; checkLinkable = true;
break; break;
default: default:
throw LIMA_CTL_EXC(InvalidValue,"Not yet managed"); THROW_CTL_ERROR(InvalidValue) << "Not yet managed";
} }
DEB_TRACE() << DEB_VAR1(checkLinkable); DEB_TRACE() << DEB_VAR1(checkLinkable);
...@@ -298,7 +303,7 @@ void SoftOpExternalMgr::_checkIfPossible(SoftOpId aSoftOpId, ...@@ -298,7 +303,7 @@ void SoftOpExternalMgr::_checkIfPossible(SoftOpId aSoftOpId,
char buffer[256]; char buffer[256];
snprintf(buffer,sizeof(buffer),"%s task %s is already active on that level", snprintf(buffer,sizeof(buffer),"%s task %s is already active on that level",
k->m_key.m_name,k->m_alias.c_str()); k->m_key.m_name,k->m_alias.c_str());
throw LIMA_CTL_EXC(Error,buffer); THROW_CTL_ERROR(Error) << buffer;
} }
} }
} }
......
...@@ -418,7 +418,7 @@ void SoftOpRoi2Spectrum::del(const std::list<int> &roiIds) ...@@ -418,7 +418,7 @@ void SoftOpRoi2Spectrum::del(const std::list<int> &roiIds)
AutoMutex aLock(m_cond.mutex()); AutoMutex aLock(m_cond.mutex());
std::list<int>::iterator i = aTmpList.begin(); std::list<int>::iterator i = aTmpList.begin();
std::list<ManagerNCounter>::iterator k = m_manager_tasks.begin(); std::list<ManagerNCounter>::iterator k = m_manager_tasks.begin();
for(int index = 1;i != aTmpList.end() && k != m_manager_tasks.end();++i) for(int index = 0;i != aTmpList.end() && k != m_manager_tasks.end();++i)
{ {
while(index != *i && k != m_manager_tasks.end()) while(index != *i && k != m_manager_tasks.end())
++k,++index; ++k,++index;
...@@ -456,7 +456,7 @@ void SoftOpRoi2Spectrum::getRoiMode(std::list<int> &aReturnList) const ...@@ -456,7 +456,7 @@ void SoftOpRoi2Spectrum::getRoiMode(std::list<int> &aReturnList) const
void SoftOpRoi2Spectrum::setRoiMode(int roiId,int mode) void SoftOpRoi2Spectrum::setRoiMode(int roiId,int mode)
{ {
AutoMutex aLock(m_cond.mutex()); AutoMutex aLock(m_cond.mutex());
int rId = 1; int rId = 0;
for(std::list<ManagerNCounter>::const_iterator i = m_manager_tasks.begin(); for(std::list<ManagerNCounter>::const_iterator i = m_manager_tasks.begin();
i != m_manager_tasks.end();++i,++rId) i != m_manager_tasks.end();++i,++rId)
{ {
...@@ -514,7 +514,7 @@ void SoftOpRoi2Spectrum::getBufferSize(int &size) const ...@@ -514,7 +514,7 @@ void SoftOpRoi2Spectrum::getBufferSize(int &size) const
void SoftOpRoi2Spectrum::readCounters(int from,std::list<RoiIdAndResults> &result) const void SoftOpRoi2Spectrum::readCounters(int from,std::list<RoiIdAndResults> &result) const
{ {
AutoMutex aLock(m_cond.mutex()); AutoMutex aLock(m_cond.mutex());
int roiIndex = 1; int roiIndex = 0;
for(std::list<ManagerNCounter>::const_iterator i = m_manager_tasks.begin(); for(std::list<ManagerNCounter>::const_iterator i = m_manager_tasks.begin();
i != m_manager_tasks.end();++i,++roiIndex) i != m_manager_tasks.end();++i,++roiIndex)
{ {
...@@ -527,7 +527,7 @@ void SoftOpRoi2Spectrum::readCounters(int from,std::list<RoiIdAndResults> &resul ...@@ -527,7 +527,7 @@ void SoftOpRoi2Spectrum::readCounters(int from,std::list<RoiIdAndResults> &resul
void SoftOpRoi2Spectrum::createImage(int roiId,int &from,Data &aData) const void SoftOpRoi2Spectrum::createImage(int roiId,int &from,Data &aData) const
{ {
AutoMutex aLock(m_cond.mutex()); AutoMutex aLock(m_cond.mutex());
int roiIndex = 1; int roiIndex = 0;
for(std::list<ManagerNCounter>::const_iterator i = m_manager_tasks.begin(); for(std::list<ManagerNCounter>::const_iterator i = m_manager_tasks.begin();
i != m_manager_tasks.end();++i,++roiIndex) i != m_manager_tasks.end();++i,++roiIndex)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment