Commit 529345be authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Jungfrau: move Data helpers from ImgProcBase to Jungfrau level

parent 996c38bc
......@@ -201,33 +201,6 @@ class Jungfrau : public Model
virtual void prepareAcq();
virtual void processFrame(Data& data) = 0;
static void updateDataSize(Data& d, Size size) {
DataDims data_dims{size.getWidth(), size.getHeight()};
if (d.empty() || (d.dimensions != data_dims)) {
d.dimensions = data_dims;
d.setBuffer(new Buffer(d.size()));
}
}
static void clearData(Data& d) {
memset(d.data(), 0, d.size());
}
static void makeDataRef(Data& src, Data& ref,
Buffer::Callback *cb) {
ref.type = src.type;
ref.dimensions = src.dimensions;
ref.frameNumber = src.frameNumber;
ref.timestamp = src.timestamp;
ref.header = src.header;
Buffer *b = new Buffer;
b->owner = Buffer::MAPPED;
b->callback = cb;
b->data = src.data();
ref.setBuffer(b);
b->unref();
}
protected:
friend class Jungfrau;
Jungfrau *m_jungfrau;
......@@ -332,6 +305,43 @@ class Jungfrau : public Model
return raw;
}
static void updateDataSize(Data& d, Size size) {
std::vector<int> data_dims{size.getWidth(), size.getHeight()};
if (d.empty() || (d.dimensions != data_dims)) {
d.dimensions = data_dims;
d.setBuffer(new Buffer(d.size()));
}
}
static void clearData(Data& d) {
memset(d.data(), 0, d.size());
}
static void makeDataRef(Data& src, Data& ref, Buffer::Callback *cb) {
ref.type = src.type;
ref.dimensions = src.dimensions;
ref.frameNumber = src.frameNumber;
ref.timestamp = src.timestamp;
ref.header = src.header;
Buffer *b = new Buffer;
b->owner = Buffer::MAPPED;
b->callback = cb;
b->data = src.data();
ref.setBuffer(b);
b->unref();
}
static void initData(Data& d, Size size, Data::TYPE type) {
std::vector<int> dims = {size.getWidth(), size.getHeight()};
if ((d.type != type) || (d.dimensions != dims)) {
d.type = type;
d.dimensions = dims;
Buffer *b = new Buffer(d.size());
d.setBuffer(b);
b->unref();
}
}
void addImgProc(ImgProcBase *img_proc);
void removeImgProc(ImgProcBase *img_proc);
void removeAllImgProc();
......
......@@ -417,22 +417,15 @@ void Jungfrau::getDetMap(Data& det_map)
bool raw = getRawMode();
FrameDim frame_dim;
getFrameDim(frame_dim, raw);
Buffer *b = new Buffer(frame_dim.getMemSize() * 2);
det_map.type = Data::UINT32;
Size size = frame_dim.getSize();
std::vector<int> dims = {size.getWidth(), size.getHeight()};
det_map.dimensions = dims;
det_map.setBuffer(b);
b->unref();
DEB_ALWAYS() << DEB_VAR1(det_map.size());
initData(det_map, frame_dim.getSize(), Data::UINT32);
// gap pixels are set to -1
if (!raw)
memset(det_map.data(), 0xff, det_map.size());
auto f = [&](auto det_geom) {
using namespace sls::Geom;
// gap pixels are set to -1
unsigned int *p = (unsigned int *) det_map.data();
memset(p, 0xff, det_map.size());
int chip_idx = 0;
det_for_each_mod(det_geom, mod, mod_geom,
mod_for_each_recv(mod_geom, recv, recv_geom,
......@@ -449,7 +442,6 @@ void Jungfrau::getDetMap(Data& det_map)
);
};
applyDetGeom(this, f, raw);
DEB_ALWAYS() << DEB_VAR1(det_map);
}
string Jungfrau::getName()
......
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