Commit 05f7b3d4 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Port to slsDetectorPackage external-frame-assembler

parent 41ace5fc
......@@ -26,7 +26,12 @@
#include "SlsDetectorFrameMap.h"
#include "SlsDetectorModel.h"
#include "sls/Receiver.h"
#include "sls/sls_detector_defs.h"
namespace sls
{
class Receiver;
}
namespace lima
{
......@@ -43,7 +48,13 @@ class Receiver
public:
typedef slsDetectorDefs::sls_detector_header sls_detector_header;
typedef slsDetectorDefs::sls_receiver_header sls_receiver_header;
typedef slsDetectorDefs::receiver_image_data ImageData;
struct ImageData {
sls_receiver_header header;
char *buffer;
int numberOfPorts;
std::bitset<MAX_NUM_PORTS> validPortData;
};
Receiver(Camera *cam, int idx, int rx_port);
~Receiver();
......@@ -62,8 +73,7 @@ public:
SlsDetector::Stats& getStats()
{ return m_stats.stats; }
void clearAllBuffers()
{ m_recv->clearAllBuffers(); }
void clearAllBuffers();
private:
friend class Camera;
......@@ -79,6 +89,9 @@ private:
}
};
struct AssemblerImpl;
bool asmRecvImage(ImageData &image_data);
bool readRecvImage(ImageData *image_data);
Camera *m_cam;
......@@ -87,6 +100,7 @@ private:
Args m_args;
bool m_gap_pixels_enable;
AutoPtr<sls::Receiver> m_recv;
AssemblerImpl *m_asm_impl;
Stats m_stats;
};
......
Subproject commit e4394a6e7bdd00a662d680bc63a9b12728044332
Subproject commit 4ab14ea02f223a1ed28ae50929d30fd299974d0e
......@@ -177,13 +177,13 @@ void BufferMgr::releaseBuffers()
{
DEB_MEMBER_FUNCT();
bool prev_release_unused;
BufferCtrlObj::getBufferMgrResizePolicy(prev_release_unused);
BufferCtrlObj::setBufferMgrResizePolicy(true);
// BufferCtrlObj::getBufferMgrResizePolicy(prev_release_unused);
// BufferCtrlObj::setBufferMgrResizePolicy(true);
if (m_acq_buffer_ctrl_obj)
m_acq_buffer_ctrl_obj->releaseBuffers();
if (m_lima_buffer_ctrl_obj)
m_lima_buffer_ctrl_obj->releaseBuffers();
BufferCtrlObj::setBufferMgrResizePolicy(prev_release_unused);
// BufferCtrlObj::setBufferMgrResizePolicy(prev_release_unused);
}
void BufferMgr::clearAllBuffers()
......
......@@ -22,10 +22,18 @@
#include "SlsDetectorCamera.h"
#include "sls/Receiver.h"
using namespace std;
using namespace lima;
using namespace lima::SlsDetector;
using namespace FrameAssembler;
struct Receiver::AssemblerImpl {
MPFrameAssemblerPtr m_asm;
};
Receiver::Receiver(Camera *cam, int idx, int rx_port)
: m_cam(cam), m_idx(idx), m_rx_port(rx_port), m_gap_pixels_enable(false)
{
......@@ -37,11 +45,14 @@ Receiver::Receiver(Camera *cam, int idx, int rx_port)
m_args.set(os.str());
start();
m_asm_impl = new AssemblerImpl();
}
Receiver::~Receiver()
{
DEB_DESTRUCTOR();
delete m_asm_impl;
}
void Receiver::start()
......@@ -54,7 +65,8 @@ void Receiver::start()
void Receiver::prepareAcq()
{
DEB_MEMBER_FUNCT();
m_recv->enableGap(m_gap_pixels_enable);
AssemblerType asm_type = m_gap_pixels_enable ? AsmWithGap : AsmRaw;
m_asm_impl->m_asm = std::move(m_recv->CreateFrameAssembler(asm_type));
m_stats.reset();
}
......@@ -92,6 +104,22 @@ void Receiver::setCPUAffinity(const RecvCPUAffinity& recv_affinity)
m_recv->setBufferNodeAffinity(fifo_node_mask, max_node);
}
inline bool Receiver::asmRecvImage(ImageData &image_data)
{
DEB_MEMBER_FUNCT();
AnyPacketBlockList blocks = m_recv->GetFramePacketBlocks();
FrameAssembler::Result res;
MPFrameAssemblerPtr::pointer a = m_asm_impl->m_asm.get();
res = a->assembleFrame(std::move(blocks), &image_data.header,
image_data.buffer);
image_data.numberOfPorts = res.nb_ports;
image_data.validPortData = res.valid_data;
bool got_data = image_data.validPortData.any();
DEB_RETURN() << DEB_VAR1(got_data);
return got_data;
}
inline bool Receiver::readRecvImage(ImageData *image_data)
{
DEB_MEMBER_FUNCT();
......@@ -105,8 +133,8 @@ inline bool Receiver::readRecvImage(ImageData *image_data)
}
DEB_TRACE() << "Action: " << action;
int ret = m_recv->getImage(*image_data);
if ((ret != 0) || (m_cam->getAcqState() == Stopping)) {
bool got_data = asmRecvImage(*image_data);
if (!got_data || (m_cam->getAcqState() == Stopping)) {
DEB_RETURN() << DEB_VAR1(false);
return false;
}
......@@ -179,3 +207,8 @@ bool Receiver::getImage(ImageData& image_data)
return true;
}
void Receiver::clearAllBuffers()
{
m_recv->clearAllBuffers();
}
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