Commit 592305eb authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Add Lima BufferCtrlObj::Sync

parent 23d9eb6d
......@@ -96,6 +96,7 @@ public:
void setAcqBufferCPUAffinity(CPUAffinity buffer_affinity);
void waitLimaFrame(FrameType frame_nb, AutoMutex& l);
char *getAcqFrameBufferPtr(FrameType frame_nb);
BufferCtrlObj *getBufferCtrlObj(BufferType type)
......@@ -126,13 +127,16 @@ public:
private:
friend class Camera;
typedef BufferCtrlObj::Sync BufferSync;
BufferMgr(Camera *cam);
Camera *m_cam;
Cond& m_cond;
Mode m_mode;
CPUAffinity m_buffer_affinity;
BufferCtrlObj *m_lima_buffer_ctrl_obj;
BufferSync *m_lima_buffer_sync;
AutoPtr<BufferCtrlObj> m_acq_buffer_ctrl_obj;
int m_max_memory;
};
......
......@@ -28,7 +28,8 @@ using namespace lima::SlsDetector;
BufferMgr::BufferMgr(Camera *cam)
: m_cam(cam), m_mode(Single), m_lima_buffer_ctrl_obj(NULL),
: m_cam(cam), m_cond(m_cam->m_cond), m_mode(Single),
m_lima_buffer_ctrl_obj(NULL),
m_max_memory(70)
{
DEB_CONSTRUCTOR();
......@@ -82,6 +83,27 @@ void BufferMgr::setLimaBufferCtrlObj(BufferCtrlObj *buffer_ctrl_obj)
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(m_lima_buffer_ctrl_obj, buffer_ctrl_obj);
m_lima_buffer_ctrl_obj = buffer_ctrl_obj;
m_lima_buffer_sync = buffer_ctrl_obj ?
buffer_ctrl_obj->getBufferSync(m_cond) : NULL;
}
void BufferMgr::waitLimaFrame(FrameType frame_nb, AutoMutex& l)
{
DEB_MEMBER_FUNCT();
if (!m_lima_buffer_ctrl_obj)
THROW_HW_ERROR(Error) << "No Lima BufferCbMgr defined";
while (true) {
BufferSync::Status status = m_lima_buffer_sync->wait(frame_nb);
switch (status) {
case BufferSync::AVAILABLE:
return;
case BufferSync::INTERRUPTED:
continue;
default:
THROW_HW_ERROR(Error) << "Lima buffer sync wait error: "
<< status;
}
}
}
char *BufferMgr::getAcqFrameBufferPtr(FrameType frame_nb)
......
......@@ -184,9 +184,10 @@ void Camera::AcqThread::threadFunction()
seq_filter.addVal(frame);
SeqFilter::Range frames = seq_filter.getSeqRange();
if (frames.nb > 0) {
AutoMutexUnlock u(l);
int f = frames.first;
do {
m_cam->m_buffer.waitLimaFrame(f, l);
AutoMutexUnlock u(l);
DEB_TRACE() << DEB_VAR1(f);
Status status = newFrameReady(f);
cont_acq = status.first;
......
Supports Markdown
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