mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 18:24:15 +02:00
Moving image size initialization into each run
This commit is contained in:
@@ -14,12 +14,15 @@ class JFH5Writer {
|
||||
|
||||
const std::string root_folder_;
|
||||
const std::string detector_name_;
|
||||
const uint32_t image_y_size_;
|
||||
const uint32_t image_x_size_;
|
||||
|
||||
static const int64_t NO_RUN_ID;
|
||||
int64_t current_run_id_ = NO_RUN_ID;
|
||||
|
||||
// Run specific variables.
|
||||
int64_t current_run_id_ = NO_RUN_ID;
|
||||
uint32_t image_y_size_ = 0;
|
||||
uint32_t image_x_size_ = 0;
|
||||
|
||||
// Open file specific variables.
|
||||
hid_t file_id_ = -1;
|
||||
hid_t image_dataset_id_ = -1;
|
||||
hid_t pulse_dataset_id_= -1;
|
||||
@@ -27,13 +30,19 @@ class JFH5Writer {
|
||||
hid_t daq_rec_dataset_id_ = -1;
|
||||
hid_t is_good_dataset_id_ = -1;
|
||||
|
||||
hid_t get_datatype(const int bits_per_pixel);
|
||||
void open_file(const std::string& output_file, const uint32_t n_images);
|
||||
void close_file();
|
||||
|
||||
public:
|
||||
JFH5Writer(const BufferUtils::DetectorConfig config);
|
||||
~JFH5Writer();
|
||||
void open_run(const int64_t run_id, const uint32_t n_images);
|
||||
|
||||
void open_run(const int64_t run_id,
|
||||
const uint32_t n_images,
|
||||
const uint32_t image_y_size,
|
||||
const uint32_t image_x_size,
|
||||
const uint32_t bits_per_pixel);
|
||||
void close_run();
|
||||
|
||||
void write_data(const int64_t run_id,
|
||||
|
||||
@@ -22,8 +22,6 @@ using namespace live_writer_config;
|
||||
JFH5Writer::JFH5Writer(const BufferUtils::DetectorConfig config):
|
||||
root_folder_(config.buffer_folder),
|
||||
detector_name_(config.detector_name),
|
||||
image_x_size_(config.image_x_size),
|
||||
image_y_size_(config.image_y_size)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,6 +30,8 @@ JFH5Writer::~JFH5Writer()
|
||||
close_file();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void JFH5Writer::open_run(const int64_t run_id, const uint32_t n_images)
|
||||
{
|
||||
close_file();
|
||||
@@ -53,6 +53,7 @@ void JFH5Writer::close_run()
|
||||
|
||||
void JFH5Writer::open_file(const string& output_file, const uint32_t n_images)
|
||||
{
|
||||
|
||||
// Create file
|
||||
auto fcpl_id = H5Pcreate(H5P_FILE_ACCESS);
|
||||
if (fcpl_id == -1) {
|
||||
@@ -217,5 +218,9 @@ void JFH5Writer::write_data(
|
||||
void JFH5Writer::write_meta(
|
||||
const int64_t run_id, const uint32_t index, const ImageMetadata& meta)
|
||||
{
|
||||
if (run_id != current_run_id_) {
|
||||
throw runtime_error("Invalid run_id.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user