mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-05 00:14:15 +02:00
Moved base buffer config to separate file
This commit is contained in:
@@ -6,29 +6,6 @@
|
||||
|
||||
namespace BufferUtils
|
||||
{
|
||||
const size_t STREAM_BLOCK_SIZE = 100;
|
||||
extern const size_t FILE_MOD;
|
||||
extern const size_t FOLDER_MOD;
|
||||
extern const std::string FILE_EXTENSION;
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct FileBufferMetadata {
|
||||
// Needed by RingBuffer
|
||||
const uint64_t frame_bytes_size = 2*512*1024*STREAM_BLOCK_SIZE;
|
||||
uint64_t buffer_slot_index;
|
||||
|
||||
uint64_t start_pulse_id;
|
||||
uint64_t stop_pulse_id;
|
||||
uint16_t module_id;
|
||||
|
||||
uint64_t pulse_id[STREAM_BLOCK_SIZE];
|
||||
uint64_t frame_index[STREAM_BLOCK_SIZE];
|
||||
uint32_t daq_rec[STREAM_BLOCK_SIZE];
|
||||
uint16_t n_received_packets[STREAM_BLOCK_SIZE];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
std::string get_filename(
|
||||
std::string root_folder,
|
||||
std::string device_name,
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef BUFFERCONFIG_HPP
|
||||
#define BUFFERCONFIG_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
namespace core_buffer {
|
||||
// How many frames we store in each file.
|
||||
// Must be power of 10 and <= than FOLDER_MOD
|
||||
const size_t FILE_MOD = 1000;
|
||||
|
||||
// How many frames go into each files folder.
|
||||
// Must be power of 10 and >= than FILE_MOD.
|
||||
const size_t FOLDER_MOD = 100000;
|
||||
|
||||
// Extension of our file format.
|
||||
const std::string FILE_EXTENSION = ".h5";
|
||||
|
||||
// How many frames do we read at once during replay.
|
||||
const size_t REPLAY_BLOCK_SIZE = 100;
|
||||
}
|
||||
|
||||
#endif //BUFFERCONFIG_HPP
|
||||
@@ -1,39 +1,34 @@
|
||||
#include "BufferUtils.hpp"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <config.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Must be power of 10 and <= than FOLDER_MOD
|
||||
const size_t BufferUtils::FILE_MOD = 1000;
|
||||
// Must be power of 10 and >= than FILE_MOD.
|
||||
const size_t BufferUtils::FOLDER_MOD = 100000;
|
||||
const std::string BufferUtils::FILE_EXTENSION = ".h5";
|
||||
|
||||
string BufferUtils::get_filename(
|
||||
std::string root_folder,
|
||||
std::string device_name,
|
||||
uint64_t pulse_id)
|
||||
{
|
||||
uint64_t folder_base = pulse_id / FOLDER_MOD;
|
||||
folder_base *= FOLDER_MOD;
|
||||
uint64_t folder_base = pulse_id / core_buffer::FOLDER_MOD;
|
||||
folder_base *= core_buffer::FOLDER_MOD;
|
||||
|
||||
uint64_t file_base = pulse_id / FILE_MOD;
|
||||
file_base *= FILE_MOD;
|
||||
uint64_t file_base = pulse_id / core_buffer::FILE_MOD;
|
||||
file_base *= core_buffer::FILE_MOD;
|
||||
|
||||
stringstream folder;
|
||||
folder << root_folder << "/";
|
||||
folder << device_name << "/";
|
||||
folder << folder_base << "/";
|
||||
folder << file_base << FILE_EXTENSION;
|
||||
folder << file_base << core_buffer::FILE_EXTENSION;
|
||||
|
||||
return folder.str();
|
||||
}
|
||||
|
||||
size_t BufferUtils::get_file_frame_index(uint64_t pulse_id)
|
||||
{
|
||||
uint64_t file_base = pulse_id / FILE_MOD;
|
||||
file_base *= FILE_MOD;
|
||||
uint64_t file_base = pulse_id / core_buffer::FILE_MOD;
|
||||
file_base *= core_buffer::FILE_MOD;
|
||||
|
||||
return pulse_id - file_base;
|
||||
}
|
||||
@@ -71,27 +66,27 @@ vector<BufferUtils::path_sufix> BufferUtils::get_path_suffixes (
|
||||
{
|
||||
vector<BufferUtils::path_sufix> result;
|
||||
|
||||
uint64_t start_file_base = start_pulse_id / FILE_MOD;
|
||||
start_file_base *= FILE_MOD;
|
||||
uint64_t start_file_base = start_pulse_id / core_buffer::FILE_MOD;
|
||||
start_file_base *= core_buffer::FILE_MOD;
|
||||
|
||||
for (
|
||||
uint64_t first_pulse_id=start_file_base;
|
||||
first_pulse_id <= stop_pulse_id;
|
||||
first_pulse_id += FILE_MOD) {
|
||||
first_pulse_id += core_buffer::FILE_MOD) {
|
||||
|
||||
uint64_t folder_base = first_pulse_id / FOLDER_MOD;
|
||||
folder_base *= FOLDER_MOD;
|
||||
uint64_t folder_base = first_pulse_id / core_buffer::FOLDER_MOD;
|
||||
folder_base *= core_buffer::FOLDER_MOD;
|
||||
|
||||
uint64_t file_base = first_pulse_id / FILE_MOD;
|
||||
file_base *= FILE_MOD;
|
||||
uint64_t file_base = first_pulse_id / core_buffer::FILE_MOD;
|
||||
file_base *= core_buffer::FILE_MOD;
|
||||
|
||||
stringstream folder;
|
||||
folder << folder_base << "/";
|
||||
folder << file_base << FILE_EXTENSION;
|
||||
folder << file_base << core_buffer::FILE_EXTENSION;
|
||||
|
||||
result.emplace_back<BufferUtils::path_sufix>(
|
||||
{first_pulse_id,
|
||||
first_pulse_id+FILE_MOD-1,
|
||||
first_pulse_id+core_buffer::FILE_MOD-1,
|
||||
folder.str()});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user