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