Commit 08d436fb authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Add SkipFrameFreq

parent 06c1a9f5
......@@ -119,6 +119,9 @@ public:
void setFramePeriod(double frame_period);
void getFramePeriod(double& frame_period);
void setSkipFrameFreq(FrameType skip_frame_freq);
void getSkipFrameFreq(FrameType& skip_frame_freq);
// setDAC: sub_mod_idx: 0-N=sub_module, -1=all
void setDAC(int sub_mod_idx, DACIndex dac_idx, int val,
bool milli_volt = false);
......@@ -279,7 +282,9 @@ private:
RecvList m_recv_list;
int m_recv_fifo_depth;
TrigMode m_trig_mode;
FrameType m_nb_frames;
FrameType m_lima_nb_frames;
FrameType m_det_nb_frames;
FrameType m_skip_frame_freq;
double m_exp_time;
double m_lat_time;
double m_frame_period;
......
......@@ -74,6 +74,9 @@ public:
void setFramePeriod(double frame_period);
void getFramePeriod(double& frame_period /Out/);
void setSkipFrameFreq(unsigned long skip_frame_freq);
void getSkipFrameFreq(unsigned long& skip_frame_freq /Out/);
// setDAC: sub_mod_idx: 0-N=module, -1=all
void setDAC(int sub_mod_idx, SlsDetector::Defs::DACIndex dac_idx,
int val, bool milli_volt = false);
......
......@@ -278,13 +278,15 @@ bool Camera::AcqThread::newFrameReady(FrameType frame)
HwFrameInfoType frame_info;
frame_info.acq_frame_nb = frame;
bool cont_acq = m_cam->m_buffer_cb_mgr->newFrameReady(frame_info);
return cont_acq && (frame < m_cam->m_nb_frames - 1);
return cont_acq && (frame < m_cam->m_lima_nb_frames - 1);
}
Camera::Camera(string config_fname)
: m_model(NULL),
m_recv_fifo_depth(1000),
m_nb_frames(1),
m_lima_nb_frames(1),
m_det_nb_frames(1),
m_skip_frame_freq(0),
m_lat_time(0),
m_recv_nb_ports(0),
m_pixel_depth(PixelDepth16),
......@@ -482,7 +484,7 @@ void Camera::setTrigMode(TrigMode trig_mode)
ExtComMode mode = static_cast<ExtComMode>(trig_mode);
m_det->setTimingMode(mode);
m_trig_mode = trig_mode;
setNbFrames(m_nb_frames);
setNbFrames(m_lima_nb_frames);
}
void Camera::getTrigMode(TrigMode& trig_mode)
......@@ -504,21 +506,40 @@ void Camera::setNbFrames(FrameType nb_frames)
<< DEB_VAR2(nb_frames, MaxFrames);
waitState(Idle);
FrameType det_nb_frames = nb_frames;
if (m_skip_frame_freq)
det_nb_frames += nb_frames / m_skip_frame_freq;
bool trig_exp = (m_trig_mode == Defs::TriggerExposure);
int cam_frames = trig_exp ? 1 : nb_frames;
int cam_triggers = trig_exp ? nb_frames : 1;
int cam_frames = trig_exp ? 1 : det_nb_frames;
int cam_triggers = trig_exp ? det_nb_frames : 1;
m_det->setNumberOfFrames(cam_frames);
m_det->setNumberOfCycles(cam_triggers);
m_nb_frames = nb_frames;
m_lima_nb_frames = nb_frames;
m_det_nb_frames = det_nb_frames;
}
void Camera::getNbFrames(FrameType& nb_frames)
{
DEB_MEMBER_FUNCT();
nb_frames = m_nb_frames;
nb_frames = m_lima_nb_frames;
DEB_RETURN() << DEB_VAR1(nb_frames);
}
void Camera::setSkipFrameFreq(FrameType skip_frame_freq)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(skip_frame_freq);
m_skip_frame_freq = skip_frame_freq;
setNbFrames(m_lima_nb_frames);
}
void Camera::getSkipFrameFreq(FrameType& skip_frame_freq)
{
DEB_MEMBER_FUNCT();
skip_frame_freq = m_skip_frame_freq;
DEB_RETURN() << DEB_VAR1(skip_frame_freq);
}
void Camera::setExpTime(double exp_time)
{
DEB_MEMBER_FUNCT();
......@@ -745,7 +766,7 @@ void Camera::prepareAcq()
if (getState() != Idle)
THROW_HW_ERROR(Error) << "Camera is not idle";
bool need_period = !m_nb_frames || (m_nb_frames > 1);
bool need_period = !m_lima_nb_frames || (m_lima_nb_frames > 1);
need_period &= ((m_trig_mode == Defs::Auto) ||
(m_trig_mode == Defs::BurstTrigger));
if (need_period && (m_lat_time > 0))
......
......@@ -424,7 +424,7 @@ int Receiver::fileStartCallback(char *fpath, char *fname, uint64_t fidx,
return 0;
}
void Receiver::portCallback(FrameType frame, int port, char *dptr,
void Receiver::portCallback(FrameType det_frame, int port, char *dptr,
uint32_t dsize)
{
DEB_MEMBER_FUNCT();
......@@ -444,14 +444,25 @@ void Receiver::portCallback(FrameType frame, int port, char *dptr,
port_stats.last_t0 = t0;
try {
if (frame >= m_cam->m_nb_frames)
if (det_frame >= m_cam->m_det_nb_frames)
THROW_HW_ERROR(Error) << "Invalid "
<< DEB_VAR2(frame, DebHex(frame));
recv_port.processFrame(frame, dptr, dsize);
<< DEB_VAR2(det_frame,
DebHex(det_frame));
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_VAR3(det_frame, skip_frame,
lima_frame);
}
if (!skip_frame)
recv_port.processFrame(lima_frame, dptr, dsize);
} catch (Exception& e) {
ostringstream err_msg;
err_msg << "Receiver::portCallback: " << e << ": "
<< DEB_VAR3(m_idx, frame, port);
<< DEB_VAR3(m_idx, det_frame, port);
Event::Code err_code = Event::CamOverrun;
Event *event = new Event(Hardware, Event::Error, Event::Camera,
err_code, err_msg.str());
......
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