Extract metadata to function

This commit is contained in:
2020-06-19 13:36:44 +02:00
parent 69907a3412
commit eca5c33719
2 changed files with 21 additions and 13 deletions
+4
View File
@@ -15,6 +15,7 @@ class JFH5Writer {
const uint64_t stop_pulse_id_;
const int pulse_id_step_;
const size_t n_images_;
const size_t n_total_pulses_;
size_t meta_write_index_;
size_t data_write_index_;
@@ -29,6 +30,9 @@ class JFH5Writer {
size_t get_n_pulses_in_range(const uint64_t start_pulse_id,
const uint64_t stop_pulse_id,
const int pulse_id_step);
void write_metadata();
void close_file();
public:
+17 -13
View File
@@ -31,6 +31,7 @@ JFH5Writer::JFH5Writer(const string& output_file,
n_images_(get_n_pulses_in_range(start_pulse_id,
stop_pulse_id,
pulse_id_step)),
n_total_pulses_(stop_pulse_id_ - start_pulse_id_ + 1),
meta_write_index_(0),
data_write_index_(0)
{
@@ -69,12 +70,10 @@ JFH5Writer::JFH5Writer(const string& output_file,
H5::PredType::NATIVE_UINT16,
image_dataspace);
auto n_total_pulses = stop_pulse_id_ - start_pulse_id_ + 1;
b_pulse_id_ = new uint64_t[n_total_pulses];
b_frame_index_= new uint64_t[n_total_pulses];
b_daq_rec_ = new uint32_t[n_total_pulses];
b_is_good_frame_ = new uint8_t[n_total_pulses];
b_pulse_id_ = new uint64_t[n_total_pulses_];
b_frame_index_= new uint64_t[n_total_pulses_];
b_daq_rec_ = new uint32_t[n_total_pulses_];
b_is_good_frame_ = new uint8_t[n_total_pulses_];
}
JFH5Writer::~JFH5Writer()
@@ -119,14 +118,8 @@ size_t JFH5Writer::get_n_pulses_in_range(
return n_pulses;
}
void JFH5Writer::close_file()
void JFH5Writer::write_metadata()
{
if (file_.getId() == -1) {
return;
}
image_dataset_.close();
hsize_t b_m_dims[2] = {n_images_, 1};
H5::DataSpace b_m_space (2, b_m_dims);
@@ -162,6 +155,17 @@ void JFH5Writer::close_file()
is_good_frame_dataset.write(
b_is_good_frame_, H5::PredType::NATIVE_UINT8, b_m_space, f_m_space);
is_good_frame_dataset.close();
}
void JFH5Writer::close_file()
{
if (file_.getId() == -1) {
return;
}
image_dataset_.close();
write_metadata();
file_.close();
}