mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-08-10 12:20:29 +02:00
Externalize check for frame destination
This commit is contained in:
+16
-6
@@ -243,19 +243,29 @@ bool H5Writer::is_file_open() const
|
|||||||
return (file.getId() != -1);
|
return (file.getId() != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool H5Writer::is_data_for_current_file(const size_t data_index)
|
||||||
|
{
|
||||||
|
if (frames_per_file) {
|
||||||
|
hsize_t frame_chunk = (data_index / frames_per_file) + 1;
|
||||||
|
|
||||||
|
// This frames does not go into this file.
|
||||||
|
if (frame_chunk != current_frame_chunk) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
hsize_t H5Writer::prepare_storage_for_data(const string& dataset_name, const size_t data_index, const std::vector<size_t>& data_shape,
|
hsize_t H5Writer::prepare_storage_for_data(const string& dataset_name, const size_t data_index, const std::vector<size_t>& data_shape,
|
||||||
const string& data_type, const string& endianness)
|
const string& data_type, const string& endianness)
|
||||||
{
|
{
|
||||||
hsize_t relative_data_index = data_index;
|
hsize_t relative_data_index = data_index;
|
||||||
|
|
||||||
// Check if we have to create a new file.
|
// Check if we have to create a new file.
|
||||||
if (frames_per_file) {
|
if (!is_data_for_current_file(data_index)) {
|
||||||
hsize_t frame_chunk = (data_index / frames_per_file) + 1;
|
hsize_t frame_chunk = (data_index / frames_per_file) + 1;
|
||||||
|
create_file(frame_chunk);
|
||||||
// This frames does not go into this file.
|
|
||||||
if (frame_chunk != current_frame_chunk) {
|
|
||||||
create_file(frame_chunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make the data_index relative to this chunk (file).
|
// Make the data_index relative to this chunk (file).
|
||||||
relative_data_index = data_index - ((frame_chunk - 1) * frames_per_file);
|
relative_data_index = data_index - ((frame_chunk - 1) * frames_per_file);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class H5Writer
|
|||||||
virtual void write_data(const std::string& dataset_name, const size_t data_index, const char* data, const std::vector<size_t>& data_shape,
|
virtual void write_data(const std::string& dataset_name, const size_t data_index, const char* data, const std::vector<size_t>& data_shape,
|
||||||
const size_t data_bytes_size, const std::string& data_type, const std::string& endianness);
|
const size_t data_bytes_size, const std::string& data_type, const std::string& endianness);
|
||||||
virtual H5::H5File& get_h5_file();
|
virtual H5::H5File& get_h5_file();
|
||||||
|
virtual bool is_data_for_current_file(const size_t data_index);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DummyH5Writer : public H5Writer
|
class DummyH5Writer : public H5Writer
|
||||||
|
|||||||
Reference in New Issue
Block a user