7#include "utils/logging.h"
10FLASHMEM run::RunConfig run::RunConfig::from_json(JsonObjectConst &json) {
16 uint64_t ic_time_ms = json[
"ic_time_ms"], ic_time_us = json[
"ic_time_us"], ic_time_ns = json[
"ic_time_ns"],
17 ic_time_def = json[
"ic_time"],
19 op_time_ms = json[
"op_time_ms"], op_time_us = json[
"op_time_us"], op_time_ns = json[
"op_time_ns"],
20 op_time_def = json[
"op_time"];
22 uint64_t us = 1000, ms = 1'000'000;
26 run.ic_time = ic_time_def + ic_time_ns + us * ic_time_us + ms * ic_time_ms;
27 run.op_time = op_time_def + op_time_ns + us * op_time_us + ms * op_time_ms;
34 if (json.containsKey(
"halt_on_overload"))
35 run.halt_on_overload = json[
"halt_on_overload"];
37 if (json.containsKey(
"streaming"))
38 run.streaming = json[
"streaming"];
40 if (json.containsKey(
"repetitive"))
41 run.repetitive = json[
"repetitive"];
43 if (json.containsKey(
"write_run_state_changes"))
44 run.write_run_state_changes = json[
"write_run_state_changes"];
46 if (json.containsKey(
"calibrate"))
47 run.calibrate = json[
"calibrate"];
53run::Run::Run(std::string
id,
const run::RunConfig &config)
54 : id(std::move(id)), config(config), daq_config{} {}
57run::Run::Run(std::string
id,
const run::RunConfig &config,
const daq::DAQConfig &daq_config)
58 : id(std::move(id)), config(config), daq_config(daq_config) {}
61run::Run run::Run::from_json(JsonObjectConst &json) {
62 auto json_run_config = json[
"config"].as<JsonObjectConst>();
63 auto run_config = RunConfig::from_json(json_run_config);
64 auto daq_config = daq::DAQConfig::from_json(json[
"daq_config"].as<JsonObjectConst>());
65 auto id = json[
"id"].as<std::string>();
66 if (
id.
size() != 32 + 4) {
67 id =
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
69 return {id, run_config, daq_config};
73run::RunStateChange run::Run::to(run::RunState new_state,
unsigned int t) {
76 return {t, old, state};