10 auto convert_to(
const DataElementType& raw_data) -> T
12 constexpr auto struct_size =
sizeof(uint64_t);
14 static_assert(
sizeof(T) == struct_size);
15 auto expanded_raw_data = std::bitset<common::BYTE_BIT_LENGTH * struct_size>(raw_data.to_ullong());
17 expanded_raw_data = expanded_raw_data << shifted_bits;
18 return std::bit_cast<T>(expanded_raw_data.to_ullong());
24 uint16_t channel_num : 6;
25 uint16_t is_over_threshold : 1;
33 struct MarkerDataCompact
42 void array_to_marker(
const DataElementType& raw_data, MarkerData& marker_data)
44 auto marker_data_compact = convert_to<MarkerDataCompact>(raw_data);
46 auto timestamp_high_bits = std::bitset<common::SRS_TIMESTAMP_HIGH_BIT_LENGTH>(
47 static_cast<uint32_t
>(marker_data_compact.timestamp_high_bits));
48 auto timestamp_low_bits = std::bitset<common::SRS_TIMESTAMP_LOW_BIT_LENGTH>(
49 static_cast<uint32_t
>(marker_data_compact.timestamp_low_bits));
50 marker_data.srs_timestamp =
static_cast<decltype(marker_data.srs_timestamp)
>(
52 marker_data.vmm_id =
static_cast<decltype(marker_data.vmm_id)
>(marker_data_compact.vmm_id);
55 void array_to_hit(
const DataElementType& raw_data, HitData& hit_data)
57 auto hit_data_compact = convert_to<HitDataCompact>(raw_data);
59 hit_data.is_over_threshold =
60 static_cast<decltype(hit_data.is_over_threshold)
>(hit_data_compact.is_over_threshold);
61 hit_data.channel_num =
static_cast<decltype(hit_data.channel_num)
>(hit_data_compact.channel_num);
62 hit_data.tdc =
static_cast<decltype(hit_data.tdc)
>(hit_data_compact.tdc);
63 hit_data.offset =
static_cast<decltype(hit_data.offset)
>(hit_data_compact.offset);
64 hit_data.vmm_id =
static_cast<decltype(hit_data.vmm_id)
>(hit_data_compact.vmm_id);
65 hit_data.adc =
static_cast<decltype(hit_data.adc)
>(hit_data_compact.adc);
66 hit_data.bc_id =
static_cast<decltype(hit_data.bc_id)
>(hit_data_compact.bc_id);
77 if (not temp_data.empty())
86 temp_data =
data.value();
91 spdlog::debug(
"Shutting down struct deserializer.");
100 auto deserialize_to = zpp::bits::in{ binary_data, zpp::bits::endian::network{}, zpp::bits::no_size{} };
103 constexpr auto header_bytes =
sizeof(
output_data_.header);
105 auto vector_size = (read_bytes - header_bytes) / element_bytes;
108 throw std::runtime_error(
"Deserialization: Wrong header type!");
121 return translated_size;
131 auto& hit_data = struct_data.
hit_data.emplace_back();
132 array_to_hit(element, hit_data);
136 auto& marker_data = struct_data.
marker_data.emplace_back();
137 array_to_marker(element, marker_data);
std::string_view InputType
asio::experimental::coro< OutputType(std::optional< InputType >)> CoroType
ReceiveDataSquence receive_raw_data_
std::bitset< common::HIT_DATA_BIT_LENGTH > DataElementType
void translate_raw_data(StructData &struct_data)
static auto check_is_hit(const DataElementType &element) -> bool
void byte_reverse_data_sq()
auto convert(std::string_view binary_data) -> std::size_t
auto generate_coro(asio::any_io_executor) -> CoroType
auto data() const -> const auto &
constexpr auto SRS_TIMESTAMP_LOW_BIT_LENGTH
constexpr auto BYTE_BIT_LENGTH
constexpr auto HIT_DATA_BIT_LENGTH
constexpr auto SRS_TIMESTAMP_HIGH_BIT_LENGTH
constexpr auto gray_to_binary(T gray_val)
constexpr auto merge_bits(const std::bitset< high_size > &high_bits, const std::bitset< low_size > &low_bits) -> std::bitset< high_size+low_size >
constexpr auto byte_swap(const std::bitset< bit_size > &bits)
std::vector< MarkerData > marker_data
Marker data.
std::vector< HitData > hit_data
Hit data.