GitLab will be upgraded on June 23th evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 77fd6f33 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by Operator for ID00

Support skipped frames in passive mode

parent 86958a47
Pipeline #46061 failed with stages
in 11 minutes and 56 seconds
......@@ -74,7 +74,10 @@ private:
last_t0 = last_t1 = Timestamp();
}
};
bool readRecvImage(FrameType lima_frame, FrameType det_frame,
ImageData *image_data=NULL);
Camera *m_cam;
int m_idx;
int m_rx_port;
......
Subproject commit aada967bccdf1d217c5d2ced5940bb9013f9eb1f
Subproject commit 7fb9448dfb7aa29e33aa5dd2d3d98298b208afef
......@@ -565,8 +565,6 @@ void Camera::setSkipFrameFreq(FrameType skip_frame_freq)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(skip_frame_freq);
if (skip_frame_freq)
THROW_HW_ERROR(NotSupported) << "Skip frame not supported yet";
m_skip_frame_freq = skip_frame_freq;
setNbFrames(m_lima_nb_frames);
}
......
......@@ -1352,16 +1352,17 @@ void Eiger::processOneFrame(AutoMutex& l)
{
AutoMutexUnlock u(l);
std::bitset<64> ok;
if (getNbRecvs() > 64)
int nb_recvs = getNbRecvs();
if (nb_recvs > 64)
THROW_HW_ERROR(Error) << "Too many receivers";
char *bptr = getFrameBufferPtr(frame);
for (int i = 0; i < getNbRecvs(); ++i)
for (int i = 0; i < nb_recvs; ++i)
ok[i] = m_recv_list[i]->processOneFrame(frame, bptr);
if (ok.none())
return;
for (int i = 0; i < getNbRecvs(); ++i)
for (int i = 0; i < nb_recvs; ++i)
if (!ok[i])
m_recv_list[i]->processBadFrame(frame, bptr);
}
......
......@@ -97,6 +97,38 @@ void Receiver::setCPUAffinity(const RecvCPUAffinity& recv_affinity)
m_recv->setFifoNodeAffinity(fifo_node_mask, max_node);
}
inline bool Receiver::readRecvImage(FrameType lima_frame, FrameType det_frame,
ImageData *image_data)
{
DEB_MEMBER_FUNCT();
ImageData skip_image_data;
const char *action = "read";
if (!image_data) {
image_data = &skip_image_data;
image_data->buffer = NULL;
action = "skip";
}
DEB_TRACE() << "To " << action << ": "
<< DEB_VAR3(m_idx, lima_frame, det_frame);
image_data->frame = det_frame;
int ret = m_recv->getImage(*image_data);
if ((ret != 0) || (m_cam->getAcqState() == Stopping))
return false;
sls_receiver_header& header = image_data->header;
FrameType recv_frame = header.detHeader.frameNumber;
if (recv_frame > m_cam->m_det_nb_frames)
THROW_HW_ERROR(Error) << "Invalid frame: "
<< DEB_VAR3(m_idx, recv_frame,
DebHex(recv_frame));
else if (recv_frame != det_frame)
THROW_HW_ERROR(Error) << "Bad frame: "
<< DEB_VAR3(m_idx, recv_frame, det_frame);
return true;
}
bool Receiver::getImage(ImageData& image_data)
{
DEB_MEMBER_FUNCT();
......@@ -109,38 +141,37 @@ bool Receiver::getImage(ImageData& image_data)
m_stats.stats.recv_exec.add(t0 - m_stats.last_t1);
m_stats.last_t0 = t0;
FrameType det_frame;
FrameType lima_frame = image_data.frame;
try {
++image_data.frame;
int ret = m_recv->getImage(image_data);
if ((ret != 0) || (m_cam->getAcqState() == Stopping))
return false;
sls_receiver_header& header = image_data.header;
det_frame = header.detHeader.frameNumber - 1;
if (det_frame >= m_cam->m_det_nb_frames)
THROW_HW_ERROR(Error) << "Invalid frame: "
<< DEB_VAR3(m_idx,
det_frame,
DebHex(det_frame));
FrameType det_frame = lima_frame + 1; // Eiger first frame is 1
bool skip_prev = false;
bool skip_last = false;
FrameType skip_freq = m_cam->m_skip_frame_freq;
bool skip_frame = false;
FrameType lima_frame = det_frame;
if (skip_freq) {
skip_frame = ((det_frame + 1) % (skip_freq + 1) == 0);
lima_frame -= det_frame / (skip_freq + 1);
DEB_TRACE() << DEB_VAR4(m_idx, det_frame,
skip_frame, lima_frame);
det_frame += lima_frame / skip_freq;
skip_prev = (lima_frame &&
(lima_frame % skip_freq == 0));
skip_last = ((det_frame + 1) == m_cam->m_det_nb_frames);
DEB_TRACE() << DEB_VAR5(m_idx, lima_frame, det_frame,
skip_prev, skip_last);
}
if (skip_frame) {
if (det_frame == m_cam->m_det_nb_frames - 1)
m_cam->processLastSkippedFrame(m_idx);
if (skip_prev && !readRecvImage(lima_frame, det_frame - 1))
return false;
if (!readRecvImage(lima_frame, det_frame, &image_data))
return false;
if (skip_last) {
if (!readRecvImage(lima_frame, det_frame + 1))
return false;
m_cam->processLastSkippedFrame(m_idx);
}
image_data.frame = lima_frame;
} catch (Exception& e) {
ostringstream name;
name << "Receiver::getImage: " << DEB_VAR2(m_idx, det_frame);
name << "Receiver::getImage: " << DEB_VAR2(m_idx, lima_frame);
m_cam->reportException(e, name.str());
return false;
}
......
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