Commit 81b06940 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron
Browse files

Port to slsDetectorPackage refactoring

parent 21e20012
Subproject commit 4ab14ea02f223a1ed28ae50929d30fd299974d0e Subproject commit b34da6f72a96d65f09e5cfc3b3061d8090ccc9e4
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
#include "SlsDetectorJungfrau.h" #include "SlsDetectorJungfrau.h"
#include "lima/MiscUtils.h" #include "lima/MiscUtils.h"
#include "sls/Geometry.h" #include "sls/detectors/jungfrau/Geometry.h"
#include "sls/Pixel.h"
#include <emmintrin.h> #include <emmintrin.h>
#include <sched.h> #include <sched.h>
...@@ -33,18 +34,17 @@ using namespace lima; ...@@ -33,18 +34,17 @@ using namespace lima;
using namespace lima::SlsDetector; using namespace lima::SlsDetector;
using namespace lima::SlsDetector::Defs; using namespace lima::SlsDetector::Defs;
#define applyDetGeom(j, f, raw) \ #define applyDetGeom(j, f, raw) \
using namespace sls::Geom::Jungfrau; \ using namespace sls::Jungfrau::Geom; \
int ifaces; \ int ifaces; \
j->getNbUDPInterfaces(ifaces); \ j->getNbUDPInterfaces(ifaces); \
auto any_nb_ifaces = AnyNbUDPIfacesFromNbUDPIfaces(ifaces); \ auto any_nb_ifaces = AnyNbUDPIfacesFromNbUDPIfaces(ifaces); \
std::visit([&](auto nb) { \ std::visit([&](auto nb) { \
constexpr int nb_udp_ifaces = nb; \ using nb_udp_ifaces = decltype(nb); \
Defs::xy det_size = j->m_det->getDetectorSize(); \ Defs::xy det_size = j->m_det->getDetectorSize(); \
auto any_geom = AnyDetGeomFromDetSize<nb_udp_ifaces>({det_size.x, \ auto any_geom = AnyDetGeomFromDetSize<nb_udp_ifaces>({det_size.x, \
det_size.y});\ det_size.y});\
std::visit([&](auto geom) { \ std::visit([&](auto const &geom) { \
if (raw) \ if (raw) \
f(geom.raw_geom); \ f(geom.raw_geom); \
else \ else \
...@@ -85,10 +85,11 @@ void Jungfrau::GainPed::Impl<M>::getDefaultCalib(Calib& calib) ...@@ -85,10 +85,11 @@ void Jungfrau::GainPed::Impl<M>::getDefaultCalib(Calib& calib)
init(calib.ped_map[g]); init(calib.ped_map[g]);
p[g][1] = (double *) calib.ped_map[g].data(); p[g][1] = (double *) calib.ped_map[g].data();
} }
auto f = [&](auto det_geom) { auto f = [&](auto const &det_geom) {
using namespace sls::Geom; using namespace sls::Geom;
det_for_each_pixel(det_geom, det_for_each_pixel(det_geom,
[&](auto &chip_view, auto &pixel) { [&](auto const &chip_view,
auto const &pixel) {
int i = chip_view.calcMapPixelIndex(pixel); int i = chip_view.calcMapPixelIndex(pixel);
for (int g = 0; g < 3; ++g) { for (int g = 0; g < 3; ++g) {
p[g][0][i] = M::DefaultCoeffs[g][0]; p[g][0][i] = M::DefaultCoeffs[g][0];
...@@ -262,7 +263,7 @@ Jungfrau::ImgProcBase::ImgProcBase(Jungfrau *jungfrau, std::string name) ...@@ -262,7 +263,7 @@ Jungfrau::ImgProcBase::ImgProcBase(Jungfrau *jungfrau, std::string name)
DEB_CONSTRUCTOR(); DEB_CONSTRUCTOR();
DEB_PARAM() << DEB_VAR1(m_name); DEB_PARAM() << DEB_VAR1(m_name);
m_nb_jungfrau_modules = m_jungfrau->getNbJungfrauModules(); m_nb_jungfrau_modules = m_jungfrau->getNbJungfrauModules();
auto f = [&](auto det_geom) { auto f = [&](auto const &det_geom) {
m_det_mods = Point(det_geom.det_mods.x, det_geom.det_mods.y); m_det_mods = Point(det_geom.det_mods.x, det_geom.det_mods.y);
DEB_TRACE() << DEB_VAR2(m_det_mods, m_nb_jungfrau_modules); DEB_TRACE() << DEB_VAR2(m_det_mods, m_nb_jungfrau_modules);
}; };
...@@ -637,7 +638,7 @@ void Jungfrau::getAcqFrameDim(FrameDim& frame_dim, bool raw) ...@@ -637,7 +638,7 @@ void Jungfrau::getAcqFrameDim(FrameDim& frame_dim, bool raw)
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR1(raw); DEB_PARAM() << DEB_VAR1(raw);
Size size; Size size;
auto f = [&](auto det_geom) { auto f = [&](auto const &det_geom) {
size = Size(det_geom.size.x, det_geom.size.y); size = Size(det_geom.size.x, det_geom.size.y);
DEB_TRACE() << DEB_VAR1(size); DEB_TRACE() << DEB_VAR1(size);
}; };
...@@ -665,7 +666,7 @@ FrameDim Jungfrau::getModuleFrameDim(int idx, bool raw) ...@@ -665,7 +666,7 @@ FrameDim Jungfrau::getModuleFrameDim(int idx, bool raw)
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(idx, raw); DEB_PARAM() << DEB_VAR2(idx, raw);
Size size; Size size;
auto f = [&](auto det_geom) { auto f = [&](auto const &det_geom) {
auto mod_geom = det_geom.getModGeom({0, 0}); auto mod_geom = det_geom.getModGeom({0, 0});
bool last_x = true; // only raw mode supported bool last_x = true; // only raw mode supported
bool last_y = (idx == getNbJungfrauModules() - 1); bool last_y = (idx == getNbJungfrauModules() - 1);
...@@ -684,13 +685,13 @@ int Jungfrau::getModuleDataOffset(int idx, bool raw) ...@@ -684,13 +685,13 @@ int Jungfrau::getModuleDataOffset(int idx, bool raw)
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
DEB_PARAM() << DEB_VAR2(idx, raw); DEB_PARAM() << DEB_VAR2(idx, raw);
int data_offset; int data_offset;
auto f = [&](auto det_geom) { auto f = [&](auto const &det_geom) {
auto mod_pos = getModulePosition(det_geom, idx); auto mod_pos = getModulePosition(det_geom, idx);
auto mod_view = det_geom.getModView({mod_pos.x, auto mod_view = det_geom.getModView({mod_pos.x,
mod_pos.y}); mod_pos.y});
auto origin = mod_view.calcViewOrigin(); auto origin = mod_view.calcViewOrigin();
int pixel_offset = mod_view.calcMapPixelIndex(origin); int pixel_offset = mod_view.calcMapPixelIndex(origin);
data_offset = pixel_offset * sls::Geom::Pixel16::depth(); data_offset = pixel_offset * sls::Pixel16::depth();
DEB_TRACE() << DEB_VAR1(data_offset); DEB_TRACE() << DEB_VAR1(data_offset);
}; };
applyDetGeom(this, f, raw); applyDetGeom(this, f, raw);
...@@ -709,14 +710,15 @@ void Jungfrau::getDetMap(Data& det_map) ...@@ -709,14 +710,15 @@ void Jungfrau::getDetMap(Data& det_map)
if (!raw) if (!raw)
memset(det_map.data(), 0xff, det_map.size()); memset(det_map.data(), 0xff, det_map.size());
auto f = [&](auto det_geom) { auto f = [&](auto const &det_geom) {
using namespace sls::Geom; using namespace sls::Geom;
unsigned int *p = (unsigned int *) det_map.data(); unsigned int *p = (unsigned int *) det_map.data();
int chip_idx = 0; int chip_idx = 0;
det_for_each_chip(det_geom, det_for_each_chip(det_geom,
[&](auto &chip, auto &chip_view) { [&](auto const &chip, auto const &chip_view) {
view_for_each_pixel(chip_view, view_for_each_pixel(chip_view,
[&](auto &chip_view, auto &pixel) { [&](auto const &chip_view,
auto const &pixel) {
int i = chip_view.calcMapPixelIndex(pixel); int i = chip_view.calcMapPixelIndex(pixel);
p[i] = chip_idx; p[i] = chip_idx;
}); });
......
...@@ -28,7 +28,9 @@ using namespace std; ...@@ -28,7 +28,9 @@ using namespace std;
using namespace lima; using namespace lima;
using namespace lima::SlsDetector; using namespace lima::SlsDetector;
using namespace FrameAssembler; using namespace sls::FrameAssembler;
using AnyPacketBlockList = sls::AnyPacketBlockList;
struct RecvImagePackets : public Receiver::ImagePackets { struct RecvImagePackets : public Receiver::ImagePackets {
using Receiver::ImagePackets::ImagePackets; using Receiver::ImagePackets::ImagePackets;
...@@ -129,15 +131,9 @@ AutoPtr<Receiver::ImagePackets> Receiver::readSkippableImagePackets() ...@@ -129,15 +131,9 @@ AutoPtr<Receiver::ImagePackets> Receiver::readSkippableImagePackets()
std::visit([&](auto &block) { std::visit([&](auto &block) {
bool valid = block; bool valid = block;
image_data->validPortData[i] = valid; image_data->validPortData[i] = valid;
if (valid && (header.frameNumber == uint64_t(-1))) { if (valid && (header.frameNumber == uint64_t(-1)) &&
for (int p = 0; p < (*block).NbPackets; ++p) { block->getNetworkHeader())
if ((*block)[p].valid()) { header = *block->getNetworkHeader();
auto packet = (*block)[p];
header = *packet.networkHeader();
break;
}
}
}
}, blocks[i]); }, blocks[i]);
} }
if (image_data->validPortData.none()) if (image_data->validPortData.none())
...@@ -221,10 +217,10 @@ AutoPtr<Receiver::ImagePackets> Receiver::readImagePackets() ...@@ -221,10 +217,10 @@ AutoPtr<Receiver::ImagePackets> Receiver::readImagePackets()
bool Receiver::asmImagePackets(ImagePackets *image_data, char *buffer) bool Receiver::asmImagePackets(ImagePackets *image_data, char *buffer)
{ {
DEB_MEMBER_FUNCT(); DEB_MEMBER_FUNCT();
FrameAssembler::Result res; sls::FrameAssembler::Result res;
MPFrameAssemblerPtr::pointer a = m_asm_impl->m_asm.get(); MPFrameAssemblerPtr::pointer a = m_asm_impl->m_asm.get();
res = a->assembleFrame(std::move(RecvImagePacketBlocks(image_data)), res = a->assembleFrame(std::move(RecvImagePacketBlocks(image_data)),
&image_data->header, buffer); buffer);
image_data->numberOfPorts = res.nb_ports; image_data->numberOfPorts = res.nb_ports;
image_data->validPortData = res.valid_data; image_data->validPortData = res.valid_data;
bool got_data = image_data->validPortData.any(); bool got_data = image_data->validPortData.any();
......
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