159 lines
3.7 KiB
C++
159 lines
3.7 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#ifndef JUNGFRAUJOCH_CBORMESSAGES_H
|
|
#define JUNGFRAUJOCH_CBORMESSAGES_H
|
|
|
|
#include <string>
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <vector>
|
|
#include "../compression/CompressionAlgorithmEnum.h"
|
|
#include "../common/SpotToSave.h"
|
|
|
|
constexpr const uint64_t user_data_release = 1;
|
|
constexpr const uint64_t user_data_magic_number = 0x52320000UL | user_data_release;
|
|
|
|
struct CBORImage {
|
|
const uint8_t *data;
|
|
size_t size; // Including compression
|
|
size_t xpixel;
|
|
size_t ypixel;
|
|
size_t pixel_depth_bytes;
|
|
bool pixel_is_signed;
|
|
bool pixel_is_float = false;
|
|
CompressionAlgorithm algorithm;
|
|
std::string channel;
|
|
};
|
|
|
|
struct DataMessage {
|
|
int64_t number = INT64_MIN;
|
|
CBORImage image;
|
|
std::vector<SpotToSave> spots;
|
|
std::vector<float> rad_int_profile;
|
|
uint64_t indexing_result; // 0 - not tried, 1 - tried and failed, 2 - tried and success
|
|
std::vector<float> indexing_lattice;
|
|
|
|
uint64_t bunch_id;
|
|
uint32_t jf_info;
|
|
float receiver_available_send_buffers;
|
|
int64_t receiver_aq_dev_delay;
|
|
|
|
uint64_t timestamp;
|
|
uint32_t timestamp_base;
|
|
|
|
uint32_t storage_cell;
|
|
|
|
uint32_t exptime;
|
|
uint32_t exptime_base;
|
|
|
|
std::string series_unique_id;
|
|
uint64_t series_id;
|
|
};
|
|
|
|
struct GoniometerAxis {
|
|
float increment;
|
|
float start;
|
|
};
|
|
|
|
struct StartMessage {
|
|
uint64_t data_file_count; // user data
|
|
|
|
float detector_distance;
|
|
float beam_center_x;
|
|
float beam_center_y;
|
|
|
|
uint64_t number_of_images;
|
|
|
|
uint64_t image_size_x;
|
|
uint64_t image_size_y;
|
|
uint64_t pixel_bit_depth; // user data
|
|
bool pixel_signed; // user data
|
|
|
|
float incident_energy;
|
|
float incident_wavelength;
|
|
|
|
float frame_time;
|
|
float count_time;
|
|
|
|
int64_t saturation_value;
|
|
int64_t min_value; // user data
|
|
|
|
float pixel_size_x;
|
|
float pixel_size_y;
|
|
float sensor_thickness;
|
|
std::string sensor_material;
|
|
|
|
CompressionAlgorithm compression_algorithm; // user data
|
|
uint64_t compression_block_size; // user data
|
|
|
|
float unit_cell[6]; // user data
|
|
uint64_t space_group_number; // user data
|
|
uint64_t max_spot_count; // user data
|
|
|
|
uint64_t storage_cell_number; // user data
|
|
uint64_t storage_cell_delay_ns;
|
|
|
|
bool pixel_mask_enabled;
|
|
|
|
std::string arm_date;
|
|
|
|
std::string sample_name; // user data
|
|
std::string file_prefix; // user data
|
|
|
|
std::vector<std::string> channels;
|
|
|
|
std::string detector_description;
|
|
std::string detector_serial_number;
|
|
std::string series_unique_id;
|
|
uint64_t series_id;
|
|
|
|
std::map<std::string, GoniometerAxis> goniometer;
|
|
float detector_translation[3];
|
|
|
|
std::string source_name;
|
|
std::string source_name_short;
|
|
std::string instrument_name;
|
|
std::string instrument_name_short;
|
|
|
|
uint64_t rad_int_bin_number;
|
|
uint64_t summation;
|
|
|
|
std::vector<float> rad_int_bin_to_q;
|
|
std::vector<float> rad_int_solid_angle_corr;
|
|
|
|
std::vector<CBORImage> pixel_mask;
|
|
std::vector<CBORImage> calibration;
|
|
|
|
size_t approx_size = 1024*1024;
|
|
|
|
// Use function below to update approx_size
|
|
void AddPixelMask(CBORImage image) {
|
|
approx_size += image.size;
|
|
pixel_mask.emplace_back(std::move(image));
|
|
}
|
|
|
|
void AddCalibration(CBORImage image) {
|
|
approx_size += image.size;
|
|
calibration.emplace_back(std::move(image));
|
|
}
|
|
};
|
|
|
|
struct EndMessage {
|
|
uint64_t number_of_images;
|
|
uint64_t max_receiver_delay;
|
|
float efficiency;
|
|
|
|
bool write_master_file;
|
|
|
|
std::string end_date;
|
|
|
|
std::string series_unique_id;
|
|
uint64_t series_id;
|
|
|
|
std::map<std::string, std::vector<float>> rad_int_result;
|
|
std::map<std::string, std::vector<uint64_t>> adu_histogram;
|
|
uint64_t adu_histogram_bin_width;
|
|
};
|
|
|
|
#endif //JUNGFRAUJOCH_CBORMESSAGES_H
|