mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-03 21:04:14 +02:00
ZMQ receives acting like assembler
This commit is contained in:
@@ -26,11 +26,9 @@ public:
|
||||
~RamBuffer();
|
||||
|
||||
void write_frame(const ModuleFrame &src_meta, const char *src_data) const;
|
||||
void read_frame(const uint64_t pulse_id,
|
||||
const uint64_t module_id,
|
||||
ModuleFrame &meta,
|
||||
char *data) const;
|
||||
void read_frame(const uint64_t pulse_id, const uint64_t module_id, ModuleFrame &meta, char *data) const;
|
||||
char* read_image(const uint64_t pulse_id) const;
|
||||
char* write_image(const ImageMetadata &src_meta, const char *src_data);
|
||||
void assemble_image(const uint64_t pulse_id, ImageMetadata &image_meta) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef SF_DAQ_BUFFER_TYPEMAP_HPP
|
||||
#define SF_DAQ_BUFFER_TYPEMAP_HPP
|
||||
|
||||
enum class TypeMap {
|
||||
VOID,
|
||||
CHAR,
|
||||
INT8,
|
||||
UINT8,
|
||||
INT16,
|
||||
UINT16,
|
||||
INT32,
|
||||
UINT32,
|
||||
INT64,
|
||||
UINT64,
|
||||
FLOAT,
|
||||
DOUBLE,
|
||||
COMPLEX_FLOAT,
|
||||
COMPLEX_DOUBLE
|
||||
};
|
||||
|
||||
struct Type{
|
||||
const size_t size;
|
||||
const int value;
|
||||
};
|
||||
|
||||
|
||||
const std::unordered_map<std::type_index, Type> TypeTable = {
|
||||
{ typeid(void), {sizeof(void), TypeMap::VOID} },
|
||||
{ typeid(char), {sizeof(char), TypeMap::CHAR} },
|
||||
{ typeid(int8_t), {sizeof(int8_t), TypeMap::INT8} },
|
||||
{ typeid(uint8_t), {sizeof(uint8_t), TypeMap::UINT8} },
|
||||
{ typeid(int16_t), {sizeof(int16_t), TypeMap::INT16} },
|
||||
{ typeid(uint16_t), {sizeof(uint16_t), TypeMap::UINT16} },
|
||||
{ typeid(int32_t), {sizeof(int32_t), TypeMap::INT32} },
|
||||
{ typeid(uint32_t), {sizeof(uint32_t), TypeMap::UINT32} },
|
||||
{ typeid(int64_t), {sizeof(int64_t), TypeMap::INT64} },
|
||||
{ typeid(uint64_t), {sizeof(uint64_t), TypeMap::UINT64} },
|
||||
{ typeid(float), {sizeof(float), TypeMap::float} },
|
||||
{ typeid(double), {sizeof(double), TypeMap::DOUBLE} },
|
||||
{ typeid(std::complex<float>), {sizeof(std::complex<float>), TypeMap::COMPLEX_FLOAT} },
|
||||
{ typeid(std::complex<double>), {sizeof(std::complex<double>), TypeMap::COMPLEX_DOUBLE} }
|
||||
};
|
||||
|
||||
const std::unordered_map<int , Type> TypeTable = {
|
||||
{ TypeMap::VOID, {sizeof(void), TypeMap::VOID} },
|
||||
{ TypeMap::CHAR, {sizeof(char), TypeMap::CHAR} },
|
||||
{ TypeMap::INT8, {sizeof(int8_t), TypeMap::INT8} },
|
||||
{ TypeMap::UINT8, {sizeof(uint8_t), TypeMap::UINT8} },
|
||||
{ TypeMap::INT16, {sizeof(int16_t), TypeMap::INT16} },
|
||||
{ TypeMap::UINT16, {sizeof(uint16_t), TypeMap::UINT16} },
|
||||
{ TypeMap::INT32, {sizeof(int32_t), TypeMap::INT32} },
|
||||
{ TypeMap::UINT32, {sizeof(uint32_t), TypeMap::UINT32} },
|
||||
{ TypeMap::INT64, {sizeof(int64_t), TypeMap::INT64} },
|
||||
{ TypeMap::UINT64, {sizeof(uint64_t), TypeMap::UINT64} },
|
||||
{ TypeMap::FLOAT, {sizeof(float), TypeMap::float} },
|
||||
{ TypeMap::DOUBLE, {sizeof(double), TypeMap::DOUBLE} },
|
||||
{ TypeMap::COMPLEX_FLOAT, {sizeof(std::complex<float>), TypeMap::COMPLEX_FLOAT} },
|
||||
{ TypeMap::COMPLEX_DOUBLE, {sizeof(std::complex<double>), TypeMap::COMPLEX_DOUBLE} }
|
||||
};
|
||||
|
||||
#endif // SF_DAQ_BUFFER_TYPEMAP_HPP
|
||||
@@ -1,9 +1,10 @@
|
||||
#ifndef SF_DAQ_BUFFER_FORMATS_HPP
|
||||
#define SF_DAQ_BUFFER_FORMATS_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "TypeMap.hpp"
|
||||
#include "buffer_config.hpp"
|
||||
#include "jungfrau.hpp"
|
||||
#include "jungfraujoch.hpp"
|
||||
@@ -24,11 +25,20 @@ struct ModuleFrame {
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct ImageMetadata {
|
||||
uint64_t pulse_id;
|
||||
uint64_t frame_index;
|
||||
uint32_t daq_rec;
|
||||
uint32_t is_good_image;
|
||||
};
|
||||
uint64_t version; // protocol version
|
||||
|
||||
uint64_t id; // pulse_id for SF, frame_index for SLS
|
||||
uint64_t height; // in pixels
|
||||
uint64_t width; // in pixels
|
||||
|
||||
uint16_t dtype; // enum of data types (uint8, 16, 32, float etc.)
|
||||
uint16_t encoding; // enum of encodings (raw, bshuf_lz4...)
|
||||
uint16_t array_id; // if you want to interleave 2 buffers in the same data stream
|
||||
uint16_t status; // Denotate some status of the images - corrupt for example.
|
||||
|
||||
uint64_t user_1; // extra field for custom needs
|
||||
uint64_t user_2; // extra field for custom needs
|
||||
}
|
||||
#pragma pack(pop)
|
||||
|
||||
struct ModuleFrameBuffer {
|
||||
|
||||
Reference in New Issue
Block a user