40 lines
1.6 KiB
C++
40 lines
1.6 KiB
C++
// Copyright (2019-2022) Paul Scherrer Institute
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include "HDF5Writer.h"
|
|
#include "HDF5NXmx.h"
|
|
|
|
HDF5Writer::HDF5Writer(const StartMessage &request)
|
|
: files(request.data_file_count) {
|
|
|
|
for (int i = 0; i < request.data_file_count; i++)
|
|
files[i] = std::make_unique<HDF5DataFile>(HDF5Metadata::DataFileName(request.file_prefix, i),
|
|
request.image_size_x, request.image_size_y,
|
|
request.pixel_bit_depth / 8,
|
|
request.pixel_signed,
|
|
request.rad_int_bin_to_q,
|
|
request.compression_algorithm,
|
|
request.max_spot_count);
|
|
}
|
|
|
|
void HDF5Writer::Write(const DataMessage& message) {
|
|
if (message.number < 0)
|
|
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "No support for negative images");
|
|
if (files.empty())
|
|
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "No file to write");
|
|
|
|
size_t file_number = message.number % files.size();
|
|
// Ignore zero size images
|
|
if (message.image.size > 0)
|
|
files[file_number]->Write(message, message.number / files.size());
|
|
}
|
|
|
|
void HDF5Writer::GetStatistics(std::vector<HDF5DataFileStatistics> &v) const {
|
|
for (const auto &f: files) {
|
|
auto tmp = f->GetStatistics();
|
|
if (tmp.total_images > 0)
|
|
v.push_back(tmp);
|
|
}
|
|
}
|
|
|