6#include <glaze/glaze.hpp>
17 std ::map<std::string, std::vector<uint64_t>>
marker_data{ {
"vmm_id", {} }, {
"srs_timestamp", {} } };
18 std ::map<std::string, std::vector<uint16_t>>
hit_data{ {
"is_over_threshold", {} },
19 {
"channel_num", {} },
43 for (
const auto& hit : hits)
45 hit_data.at(
"is_over_threshold").push_back(
static_cast<uint16_t
>(hit.is_over_threshold));
46 hit_data.at(
"channel_num").push_back(hit.channel_num);
47 hit_data.at(
"tdc").push_back(hit.tdc);
48 hit_data.at(
"offset").push_back(hit.offset);
49 hit_data.at(
"vmm_id").push_back(hit.vmm_id);
50 hit_data.at(
"adc").push_back(hit.adc);
51 hit_data.at(
"bc_id").push_back(hit.bc_id);
63 for (
const auto& marker : markers)
66 marker_data.at(
"srs_timestamp").push_back(marker.srs_timestamp);
77 using InputFuture = boost::shared_future<std::optional<InputType>>;
78 using OutputFuture = boost::unique_future<std::optional<OutputType>>;
81 explicit Json(asio::thread_pool& thread_pool,
const std::string& filename)
83 ,
file_stream_{ filename, std::ios::out | std::ios::trunc }
87 spdlog::critical(
"JsonWriter: cannot open the file with filename {:?}", filename);
88 throw std::runtime_error(
"Error occured with JsonWriter");
99 auto write(
auto pre_future) -> boost::unique_future<std::optional<int>>
120 if (data_struct !=
nullptr)
125 auto data_temp =
co_yield res;
126 if (data_temp.has_value())
128 data_struct = data_temp.value();
134 spdlog::info(
"JSON file {} is closed successfully",
filename_);
156 spdlog::critical(
"JsonWriter: cannot interpret data struct to json. Error: {}",
157 error_code.custom_error_message);
158 throw std::runtime_error(
"Error occured with JsonWriter");
std::string string_buffer_
asio::experimental::coro< OutputType(std::optional< InputType >)> CoroType
static auto get_convert_mode() -> process::DataConvertOptions
CompactExportData data_buffer_
Json(asio::thread_pool &thread_pool, const std::string &filename)
auto write(auto pre_future) -> boost::unique_future< std::optional< int > >
static constexpr auto IsStructType
boost::shared_future< std::optional< InputType > > InputFuture
const StructData * InputType
auto generate_coro(asio::any_io_executor) -> CoroType
std::fstream file_stream_
boost::unique_future< std::optional< OutputType > > OutputFuture
void write_json(const StructData &data_struct)
auto create_coro_future(auto &coro, auto &&pre_fut)
void coro_sync_start(auto &coro, auto &&... args)
ReceiveDataHeader header
Header data.
std::vector< MarkerData > marker_data
Marker data.
std::vector< HitData > hit_data
Hit data.
void fill_hit_data(const std::vector< HitData > &hits)
std ::map< std::string, std::vector< uint64_t > > marker_data
std ::map< std::string, std::vector< uint16_t > > hit_data
void fill_marker_data(const std::vector< MarkerData > &markers)
void set_value(const StructData &data_struct)