33 lines
1.0 KiB
C++
33 lines
1.0 KiB
C++
// Copyright (2019-2024) Paul Scherrer Institute
|
|
|
|
#include "HDF5DataFilePluginROI.h"
|
|
|
|
#define RESERVE_IMAGES 1000
|
|
|
|
void HDF5DataFilePluginROI::OpenFile(HDF5File &data_file, const DataMessage &msg) {}
|
|
|
|
void HDF5DataFilePluginROI::Write(const DataMessage &msg, uint64_t image_number) {
|
|
for (const auto &r: msg.roi) {
|
|
if (roi_data.find(r.first) != roi_data.end()) {
|
|
roi_data[r.first].max.reserve(RESERVE_IMAGES);
|
|
roi_data[r.first].sum.reserve(RESERVE_IMAGES);
|
|
}
|
|
roi_data[r.first].max[image_number] = r.second.max_count;
|
|
roi_data[r.first].sum[image_number] = r.second.sum;
|
|
}
|
|
}
|
|
|
|
void HDF5DataFilePluginROI::WriteFinal(HDF5File &data_file) {
|
|
if (roi_data.empty())
|
|
return;
|
|
|
|
HDF5Group group(data_file, "/entry/roi");
|
|
group.NXClass("NXcollection");
|
|
|
|
for (const auto &r: roi_data) {
|
|
HDF5Group group_roi(data_file, "/entry/roi/" + r.first);
|
|
group.SaveVector("max", r.second.max.vec());
|
|
group.SaveVector("sum", r.second.sum.vec());
|
|
}
|
|
}
|