9 #include <fmt/format.h>
10 #include <string_view>
19 using Seconds = std::chrono::duration<double, std::ratio<1>>;
23 status.setState(full_state.state);
24 status.setSubState(full_state.substate);
25 status.setError(rhs.
error);
26 status.setResult(rhs.
result);
28 std::chrono::time_point_cast<Seconds>(rhs.
timestamp).time_since_epoch().count());
31 status.setMessage(j.dump(2));
37 using Seconds = std::chrono::duration<double, std::ratio<1>>;
38 status.
id = rhs.getId();
39 status.
file_id = rhs.getFileId();
41 status.
error = rhs.getError();
42 status.
result = rhs.getResult();
44 std::chrono::duration_cast<Status::TimePoint::duration>(Seconds(rhs.getTimestamp())));
48 std::filesystem::space_info&
49 operator<<(std::filesystem::space_info& space, daqif::StorageStatus
const& rhs) {
50 space.available = rhs.getAvailable();
51 space.capacity = rhs.getCapacity();
52 space.free = rhs.getFree();
56 daqif::StorageStatus&
operator<<(daqif::StorageStatus& storage, std::filesystem::space_info& rhs) {
57 storage.setAvailable(rhs.available);
58 storage.setCapacity(rhs.capacity);
59 storage.setFree(rhs.free);
66 case State::NotStarted:
67 return {daqif::StateAcquiring, daqif::NotStarted};
69 return {daqif::StateAcquiring, daqif::Starting};
70 case State::Acquiring:
71 return {daqif::StateAcquiring, daqif::Acquiring};
73 return {daqif::StateAcquiring, daqif::Stopping};
75 return {daqif::StateAcquiring, daqif::Stopped};
76 case State::AbortingAcquiring:
77 return {daqif::StateAcquiring, daqif::Aborting};
79 case State::NotScheduled:
80 return {daqif::StateMerging, daqif::NotScheduled};
81 case State::Scheduled:
82 return {daqif::StateMerging, daqif::Scheduled};
84 return {daqif::StateMerging, daqif::Transferring};
86 return {daqif::StateMerging, daqif::Merging};
87 case State::Releasing:
88 return {daqif::StateMerging, daqif::Releasing};
89 case State::AbortingMerging:
90 return {daqif::StateMerging, daqif::Aborting};
93 return {daqif::StateCompleted, daqif::Completed};
95 return {daqif::StateCompleted, daqif::Aborted};
98 return {daqif::StateUndefined, daqif::Undefined};
106 case daqif::NotStarted:
107 return State::NotStarted;
108 case daqif::Starting:
109 return State::Starting;
110 case daqif::Acquiring:
111 return State::Acquiring;
112 case daqif::Stopping:
113 return State::Stopping;
115 return State::Stopped;
117 case daqif::NotScheduled:
118 return State::NotScheduled;
119 case daqif::Scheduled:
120 return State::Scheduled;
121 case daqif::Transferring:
125 case daqif::Releasing:
126 return State::Releasing;
128 case daqif::Completed:
131 case daqif::Aborting:
132 return (state.
state == daqif::StateAcquiring) ? State::AbortingAcquiring
133 : State::AbortingMerging;
135 return State::Aborted;
137 throw std::invalid_argument(
138 fmt::format(
"Invalid daqif::DaqSubState value {:d}", state.
substate));
142 std::string_view
ToString(daqif::DaqState state) noexcept {
143 using namespace std::string_view_literals;
145 case daqif::StateAcquiring:
146 return "StateAcquiring";
147 case daqif::StateMerging:
148 return "StateMerging";
149 case daqif::StateCompleted:
150 return "StateCompleted";
151 case daqif::DaqState::StateUndefined:
158 std::string_view
ToString(daqif::DaqSubState state) noexcept {
159 using namespace std::string_view_literals;
161 case daqif::DaqSubState::NotStarted:
163 case daqif::DaqSubState::Starting:
165 case daqif::DaqSubState::Acquiring:
167 case daqif::DaqSubState::Stopping:
169 case daqif::DaqSubState::Stopped:
171 case daqif::DaqSubState::Aborting:
173 case daqif::DaqSubState::Aborted:
175 case daqif::DaqSubState::NotScheduled:
176 return "NotScheduled";
177 case daqif::DaqSubState::Scheduled:
179 case daqif::DaqSubState::Transferring:
180 return "Transferring";
181 case daqif::DaqSubState::Merging:
183 case daqif::DaqSubState::Releasing:
185 case daqif::DaqSubState::Completed:
187 case daqif::DaqSubState::Undefined: