Commit 56330aed authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Move FrameQueue from Camera to AcqThread

parent 93efac4d
......@@ -294,9 +294,14 @@ private:
"SlsDetector");
public:
AcqThread(Camera *cam);
void queueFinishedFrame(FrameType frame);
virtual void start();
void stop(bool wait);
protected:
virtual void threadFunction();
private:
class ExceptionCleanUp : Thread::ExceptionCleanUp
{
......@@ -316,7 +321,7 @@ private:
Camera *m_cam;
Cond& m_cond;
State& m_state;
FrameQueue& m_frame_queue;
FrameQueue m_frame_queue;
};
struct PortStats {
......@@ -355,7 +360,6 @@ private:
void processRecvFileStart(int recv_idx, uint32_t dsize);
void processRecvPort(int port_idx, FrameType frame, char *dptr,
uint32_t dsize);
void frameFinished(FrameType frame);
bool checkLostPackets();
FrameType getLastReceivedFrame();
......@@ -407,7 +411,6 @@ private:
AutoPtr<BufferThread, true> m_buffer_thread;
AutoPtr<AcqThread> m_acq_thread;
State m_state;
FrameQueue m_frame_queue;
double m_new_frame_timeout;
double m_abort_sleep_time;
bool m_tol_lost_packets;
......
......@@ -297,7 +297,7 @@ void Camera::BufferThread::processFinishInfo(const FinishInfo& finfo)
}
SortedIntList::const_iterator it, end = finfo.finished.end();
for (it = finfo.finished.begin(); it != end; ++it)
m_cam->frameFinished(*it);
m_cam->m_acq_thread->queueFinishedFrame(*it);
} catch (Exception& e) {
ostringstream err_msg;
err_msg << "BufferThread::processRecvPort: " << e;
......@@ -330,12 +330,17 @@ Camera::AcqThread::ExceptionCleanUp::~ExceptionCleanUp()
}
Camera::AcqThread::AcqThread(Camera *cam)
: m_cam(cam), m_cond(m_cam->m_cond), m_state(m_cam->m_state),
m_frame_queue(m_cam->m_frame_queue)
: m_cam(cam), m_cond(m_cam->m_cond), m_state(m_cam->m_state)
{
DEB_CONSTRUCTOR();
}
void Camera::AcqThread::start()
{
DEB_MEMBER_FUNCT();
m_state = Starting;
start();
Thread::start();
struct sched_param param;
param.sched_priority = sched_get_priority_min(SCHED_RR);
......@@ -427,6 +432,15 @@ void Camera::AcqThread::threadFunction()
m_cond.broadcast();
}
void Camera::AcqThread::queueFinishedFrame(FrameType frame)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(frame);
AutoMutex l = m_cam->lock();
m_frame_queue.push(frame);
m_cond.broadcast();
}
void Camera::AcqThread::cleanUp()
{
DEB_MEMBER_FUNCT();
......@@ -965,9 +979,6 @@ void Camera::prepareAcq()
m_frame_map.setBufferSize(nb_buffers);
m_frame_map.clear();
m_prev_ifa.clear();
DEB_TRACE() << DEB_VAR1(m_frame_queue.size());
while (!m_frame_queue.empty())
m_frame_queue.pop();
for (int i = 0; i < nb_ports; ++i) {
m_port_stats[i].reset();
m_buffer_thread[i].prepareAcq();
......@@ -993,6 +1004,7 @@ void Camera::startAcq()
m_buffer_cb_mgr->setStartTimestamp(Timestamp::now());
m_acq_thread = new AcqThread(this);
m_acq_thread->start();
}
void Camera::stopAcq()
......@@ -1038,15 +1050,6 @@ void Camera::processRecvPort(int port_idx, FrameType frame, char *dptr,
port_stats.stats.new_finish.add(t1 - t0);
}
void Camera::frameFinished(FrameType frame)
{
DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(frame);
AutoMutex l = lock();
m_frame_queue.push(frame);
m_cond.broadcast();
}
bool Camera::checkLostPackets()
{
DEB_MEMBER_FUNCT();
......
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