5#include <proto/main.pb.h>
8#include "utils/logging.h"
10#include "protocol/protocol_oob.h"
14 switch (time.prefix) {
16 prefix = 1'000'000'000;
29 return prefix * time.value;
32run::RunConfig run::RunConfig::from_buf(
const pb_RunConfig &config) {
43 if (config.has_halt_on_overload)
44 run.halt_on_overload = config.halt_on_overload;
46 if (config.has_repetitive)
47 run.streaming = config.streaming;
49 if (config.has_repetitive)
50 run.repetitive = config.repetitive;
52 if (config.has_write_run_state_changes)
53 run.write_run_state_changes = config.write_run_state_changes;
58run::CalibrationConfig run::CalibrationConfig::from(
const pb_CalibrationConfig &cfg) {
59 auto&
carrier = carrier::Carrier::get();
60 bool is_leader = cfg.has_leader && std::string(cfg.leader.path) ==
carrier.get_entity_id();
61 return {cfg.enabled, is_leader};
67 const RunConfig &config,
68 std::unique_ptr<RunStateChangeHandler> state_change_handler,
69 std::unique_ptr<RunDataHandler> data_handler,
70 const daq::DAQConfig &daq_config,
71 const mode::SyncConfig &sync_config,
72 const CalibrationConfig &calibration_config
76 daq_config(daq_config),
77 sync_config(sync_config),
78 calibration_config(calibration_config),
79 state_change_handler(std::move(state_change_handler)),
80 data_handler(std::move(data_handler)) {
85run::Run run::Run::decode(
86 const pb_StartRunCommand& start_run_command,
87 std::unique_ptr<RunStateChangeHandler> state_change_handler,
88 std::unique_ptr<RunDataHandler> data_handler
90 auto run_config = RunConfig::from_buf(start_run_command.run_config);
91 auto daq_config = daq::DAQConfig::from_buf(start_run_command.daq_config);
92 auto sync_config = mode::SyncConfig::from_pb(start_run_command.sync_config);
93 auto calibration_config = CalibrationConfig::from(start_run_command.calibration_config);
95 start_run_command.run.id,
97 std::move(state_change_handler),
98 std::move(data_handler),
106run::RunStateChange run::Run::to(run::RunState new_state,
unsigned int t) {
109 return {t, old, state};
uint64_t time2nanos(pb_Time time)