Commit 21e20012 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

Fix issue on remaining PacketBlocks in Camera::AcqThread & Reconstruction

parent f9b7b38c
......@@ -73,14 +73,14 @@ public:
virtual void prepare();
void addFramePackets(DetFrameImagePackets det_frame_packets);
bool addFramePackets(DetFrameImagePackets det_frame_packets);
Data getRawData(Data& data);
virtual Data process(Data& data);
virtual Data processModel(Data& data) = 0;
virtual void cleanUp();
virtual void stop();
private:
struct ThreadData {
......@@ -98,6 +98,7 @@ private:
FrameDim m_raw_frame_dim;
Mutex m_mutex;
FramePacketMap m_frame_packet_map;
bool m_stopped;
};
} // namespace SlsDetector
......
......@@ -191,7 +191,8 @@ void Camera::AcqThread::threadFunction()
auto get_next_frame = [&]() {
DetFrameImagePackets packets = readRecvPackets(next_frame++);
FrameType frame = packets.first;
reconstruct->addFramePackets(std::move(packets));
if (!reconstruct->addFramePackets(std::move(packets)))
frame = -1;
return frame;
};
......@@ -203,6 +204,8 @@ void Camera::AcqThread::threadFunction()
frame = get_next_frame();
DEB_TRACE() << DEB_VAR2(next_frame, frame);
}
if ((frame == -1) || (m_state == StopReq))
break;
m_cam->m_buffer.waitLimaFrame(frame, l);
{
AutoMutexUnlock u(l);
......@@ -212,6 +215,10 @@ void Camera::AcqThread::threadFunction()
had_frames = true;
}
}
{
AutoMutexUnlock u(l);
m_frame_packet_map.clear();
}
AcqState prev_state = m_state;
......@@ -294,11 +301,6 @@ DetFrameImagePackets Camera::AcqThread::readRecvPackets(FrameType frame)
}
}
if (stopped()) {
det_frame_packets.second.clear();
m_frame_packet_map.clear();
}
return det_frame_packets;
}
......@@ -957,7 +959,7 @@ void Camera::stopAcq()
Reconstruction *r = m_model ? m_model->getReconstruction() : NULL;
if (r)
r->cleanUp();
r->stop();
m_global_cpu_affinity_mgr.stopAcq();
AutoMutex l = lock();
......
......@@ -110,7 +110,12 @@ void Reconstruction::prepare()
model->getAcqFrameDim(m_raw_frame_dim, m_cam->m_raw_mode);
AutoMutex l(m_mutex);
m_frame_packet_map.clear();
m_stopped = false;
if (!m_frame_packet_map.empty()) {
DEB_ERROR() << "m_frame_packet_map not empty!";
AutoMutexUnlock u(l);
m_frame_packet_map.clear();
}
}
Data Reconstruction::getRawData(Data& data)
......@@ -150,26 +155,35 @@ void Reconstruction::releaseThreadData(void *thread_data)
delete d;
}
void Reconstruction::cleanUp()
void Reconstruction::stop()
{
DEB_MEMBER_FUNCT();
AutoMutex l(m_mutex);
if (m_stopped)
return;
m_stopped = true;
l.unlock();
m_frame_packet_map.clear();
}
void Reconstruction::addFramePackets(DetFrameImagePackets det_frame_packets)
bool Reconstruction::addFramePackets(DetFrameImagePackets det_frame_packets)
{
DEB_MEMBER_FUNCT();
AutoMutex l(m_mutex);
if (m_stopped)
return false;
m_frame_packet_map.emplace(std::move(det_frame_packets));
return true;
}
Data Reconstruction::process(Data& data)
{
DEB_MEMBER_FUNCT();
FrameType frame = data.frameNumber;
AutoMutex l(m_mutex);
if (m_stopped)
return data;
FrameType frame = data.frameNumber;
FramePacketMap::iterator it = m_frame_packet_map.find(frame);
if (it == m_frame_packet_map.end())
return data;
......
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