mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 01:22:23 +02:00
Add device name and root folder to constructor
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <H5Cpp.h>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
class FastH5Writer {
|
||||
|
||||
@@ -14,6 +16,8 @@ class FastH5Writer {
|
||||
const uint16_t y_frame_size_;
|
||||
const uint16_t x_frame_size_;
|
||||
const size_t frame_bytes_size_;
|
||||
const std::string device_name_;
|
||||
const std::string root_folder_;
|
||||
|
||||
std::string current_output_filename_;
|
||||
H5::H5File current_output_file_;
|
||||
@@ -21,15 +25,24 @@ class FastH5Writer {
|
||||
uint64_t current_pulse_id_;
|
||||
size_t current_frame_index_;
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<char[]>> buffers_;
|
||||
std::unordered_map<std::string, H5::DataSet> datasets_;
|
||||
|
||||
std::unordered_map<std::string, H5::PredType> scalar_metadata_;
|
||||
|
||||
void create_datasets();
|
||||
void close_file();
|
||||
|
||||
public:
|
||||
FastH5Writer(
|
||||
const size_t n_frames_per_file,
|
||||
const uint16_t y_frame_size,
|
||||
const uint16_t x_frame_size);
|
||||
const uint16_t x_frame_size,
|
||||
const std::string& device_name,
|
||||
const std::string& root_folder);
|
||||
|
||||
template <class T> void add_metadata(const std::string& metadata_name);
|
||||
template <class T> void add_scalar_metadata(
|
||||
const std::string& metadata_name);
|
||||
|
||||
void set_pulse_id(const uint64_t pulse_id);
|
||||
|
||||
|
||||
@@ -48,12 +48,13 @@ int main (int argc, char *argv[]) {
|
||||
const string str_latest_filename (
|
||||
root_folder + "/" + device_name + "/LATEST");
|
||||
|
||||
FastH5Writer writer(BufferUtils::FILE_MOD, 512, 1024);
|
||||
FastH5Writer writer(
|
||||
BufferUtils::FILE_MOD, 512, 1024, device_name, root_folder);
|
||||
|
||||
writer.add_metadata<uint64_t>("pulse_id");
|
||||
writer.add_metadata<uint64_t>("frame_id");
|
||||
writer.add_metadata<uint32_t>("daq_rec");
|
||||
writer.add_metadata<uint16_t>("received_packets");
|
||||
writer.add_scalar_metadata<uint64_t>("pulse_id");
|
||||
writer.add_scalar_metadata<uint64_t>("frame_id");
|
||||
writer.add_scalar_metadata<uint32_t>("daq_rec");
|
||||
writer.add_scalar_metadata<uint16_t>("received_packets");
|
||||
|
||||
while (true) {
|
||||
auto data = ring_buffer.read();
|
||||
|
||||
Reference in New Issue
Block a user