mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-06 03:54:12 +02:00
Rename buffer writer
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
class FastH5Writer {
|
||||
class BufferH5Writer {
|
||||
|
||||
const uint16_t CHUNKING_FACTOR = 1;
|
||||
|
||||
@@ -39,14 +39,14 @@ class FastH5Writer {
|
||||
const H5::DataType data_type);
|
||||
|
||||
public:
|
||||
FastH5Writer(
|
||||
BufferH5Writer(
|
||||
const size_t n_frames_per_file,
|
||||
const uint16_t y_frame_size,
|
||||
const uint16_t x_frame_size,
|
||||
const std::string& device_name,
|
||||
const std::string& root_folder);
|
||||
|
||||
virtual ~FastH5Writer();
|
||||
virtual ~BufferH5Writer();
|
||||
|
||||
template <class T> void add_scalar_metadata(
|
||||
const std::string& metadata_name);
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <BufferUtils.hpp>
|
||||
#include "FastH5Writer.hpp"
|
||||
#include "BufferH5Writer.hpp"
|
||||
#include <chrono>
|
||||
#include <WriterUtils.hpp>
|
||||
#include <cstring>
|
||||
@@ -11,7 +11,7 @@ extern "C"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FastH5Writer::FastH5Writer(
|
||||
BufferH5Writer::BufferH5Writer(
|
||||
const size_t n_frames_per_file,
|
||||
const uint16_t y_frame_size,
|
||||
const uint16_t x_frame_size,
|
||||
@@ -32,7 +32,7 @@ FastH5Writer::FastH5Writer(
|
||||
{
|
||||
}
|
||||
|
||||
void FastH5Writer::create_file(const string& filename)
|
||||
void BufferH5Writer::create_file(const string& filename)
|
||||
{
|
||||
{
|
||||
current_output_file_ = H5::H5File(filename,
|
||||
@@ -92,12 +92,12 @@ void FastH5Writer::create_file(const string& filename)
|
||||
|
||||
}
|
||||
|
||||
FastH5Writer::~FastH5Writer()
|
||||
BufferH5Writer::~BufferH5Writer()
|
||||
{
|
||||
close_file();
|
||||
}
|
||||
|
||||
void FastH5Writer::close_file() {
|
||||
void BufferH5Writer::close_file() {
|
||||
current_output_filename_ = "";
|
||||
current_output_file_.close();
|
||||
current_image_dataset_.close();
|
||||
@@ -115,7 +115,7 @@ void FastH5Writer::close_file() {
|
||||
buffers_.clear();
|
||||
}
|
||||
|
||||
void FastH5Writer::set_pulse_id(const uint64_t pulse_id)
|
||||
void BufferH5Writer::set_pulse_id(const uint64_t pulse_id)
|
||||
{
|
||||
current_pulse_id_ = pulse_id;
|
||||
current_frame_index_ = BufferUtils::get_file_frame_index(pulse_id);
|
||||
@@ -140,7 +140,7 @@ void FastH5Writer::set_pulse_id(const uint64_t pulse_id)
|
||||
}
|
||||
}
|
||||
|
||||
void FastH5Writer::write_data(const char *buffer)
|
||||
void BufferH5Writer::write_data(const char *buffer)
|
||||
{
|
||||
hsize_t buff_dim[2] = {y_frame_size_, x_frame_size_};
|
||||
H5::DataSpace buffer_space (2, buff_dim);
|
||||
@@ -162,7 +162,7 @@ void FastH5Writer::write_data(const char *buffer)
|
||||
}
|
||||
|
||||
template <>
|
||||
void FastH5Writer::write_scalar_metadata<uint64_t>(
|
||||
void BufferH5Writer::write_scalar_metadata<uint64_t>(
|
||||
const std::string& name,
|
||||
const void* value)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ void FastH5Writer::write_scalar_metadata<uint64_t>(
|
||||
}
|
||||
|
||||
template <>
|
||||
void FastH5Writer::write_scalar_metadata<uint32_t>(
|
||||
void BufferH5Writer::write_scalar_metadata<uint32_t>(
|
||||
const std::string& name,
|
||||
const void* value)
|
||||
{
|
||||
@@ -178,14 +178,14 @@ void FastH5Writer::write_scalar_metadata<uint32_t>(
|
||||
}
|
||||
|
||||
template <>
|
||||
void FastH5Writer::write_scalar_metadata<uint16_t>(
|
||||
void BufferH5Writer::write_scalar_metadata<uint16_t>(
|
||||
const std::string& name,
|
||||
const void* value)
|
||||
{
|
||||
write_scalar_metadata(name, value, H5::PredType::NATIVE_UINT16);
|
||||
}
|
||||
|
||||
void FastH5Writer::write_scalar_metadata(
|
||||
void BufferH5Writer::write_scalar_metadata(
|
||||
const std::string& name,
|
||||
const void* value,
|
||||
const H5::DataType data_type)
|
||||
@@ -212,21 +212,21 @@ void FastH5Writer::write_scalar_metadata(
|
||||
}
|
||||
|
||||
template <>
|
||||
void FastH5Writer::add_scalar_metadata<uint64_t>(
|
||||
void BufferH5Writer::add_scalar_metadata<uint64_t>(
|
||||
const std::string& metadata_name)
|
||||
{
|
||||
scalar_metadata_.insert({metadata_name, H5::PredType::NATIVE_UINT64});
|
||||
}
|
||||
|
||||
template <>
|
||||
void FastH5Writer::add_scalar_metadata<uint32_t>(
|
||||
void BufferH5Writer::add_scalar_metadata<uint32_t>(
|
||||
const std::string& metadata_name)
|
||||
{
|
||||
scalar_metadata_.insert({metadata_name, H5::PredType::NATIVE_UINT32});
|
||||
}
|
||||
|
||||
template <>
|
||||
void FastH5Writer::add_scalar_metadata<uint16_t>(
|
||||
void BufferH5Writer::add_scalar_metadata<uint16_t>(
|
||||
const std::string& metadata_name)
|
||||
{
|
||||
scalar_metadata_.insert({metadata_name, H5::PredType::NATIVE_UINT16});
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "FastH5Writer.hpp"
|
||||
#include "BufferH5Writer.hpp"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace core_buffer;
|
||||
@@ -17,7 +17,7 @@ TEST(FastH5Writer, basic_interaction)
|
||||
metadata.daq_rec = 3;
|
||||
metadata.n_recv_packets = 128;
|
||||
|
||||
FastH5Writer writer(
|
||||
BufferH5Writer writer(
|
||||
core_buffer::FILE_MOD, 512, 1024, device_name, root_folder);
|
||||
|
||||
writer.add_scalar_metadata<uint64_t>("pulse_id");
|
||||
@@ -100,7 +100,7 @@ TEST(FastH5Writer, SWMR)
|
||||
image_ptr[i] = 99;
|
||||
}
|
||||
|
||||
FastH5Writer writer(
|
||||
BufferH5Writer writer(
|
||||
FILE_MOD, MODULE_Y_SIZE, MODULE_X_SIZE, device_name, root_folder);
|
||||
writer.add_scalar_metadata<uint64_t>("pulse_id");
|
||||
writer.set_pulse_id(0);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdexcept>
|
||||
#include <RingBuffer.hpp>
|
||||
#include <UdpRecvModule.hpp>
|
||||
#include <FastH5Writer.hpp>
|
||||
#include <BufferH5Writer.hpp>
|
||||
#include <FastQueue.hpp>
|
||||
#include "zmq.h"
|
||||
#include "buffer_config.hpp"
|
||||
@@ -60,7 +60,7 @@ int main (int argc, char *argv[]) {
|
||||
uint64_t n_missed_frames = 0;
|
||||
uint64_t last_pulse_id = 0;
|
||||
|
||||
FastH5Writer writer(device_name, root_folder);
|
||||
BufferH5Writer writer(device_name, root_folder);
|
||||
|
||||
int slot_id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user