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());
30 nlohmann::json j = rhs.
alerts;
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);
67 return {daqif::StateAcquiring, daqif::NotStarted};
69 return {daqif::StateAcquiring, daqif::Starting};
71 return {daqif::StateAcquiring, daqif::Acquiring};
73 return {daqif::StateAcquiring, daqif::Stopping};
75 return {daqif::StateAcquiring, daqif::Stopped};
77 return {daqif::StateAcquiring, daqif::Aborting};
80 return {daqif::StateMerging, daqif::NotScheduled};
82 return {daqif::StateMerging, daqif::Scheduled};
84 return {daqif::StateMerging, daqif::Transferring};
86 return {daqif::StateMerging, daqif::Merging};
88 return {daqif::StateMerging, daqif::Releasing};
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:
108 case daqif::Starting:
110 case daqif::Acquiring:
112 case daqif::Stopping:
117 case daqif::NotScheduled:
119 case daqif::Scheduled:
121 case daqif::Transferring:
125 case daqif::Releasing:
128 case daqif::Completed:
131 case daqif::Aborting:
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:
Declares JSON support for serialization.
Contains support functions for daqif.
Declares daq::State and related functions.
daqif::DaqStatus & operator<<(daqif::DaqStatus &status, daq::Status const &rhs)
Convert daq::Status -> daqif::DaqStatus by populating from rhs.
daqif::FullState MakeState(State state) noexcept
Converts daq::State to DaqSubstate.
std::string_view ToString(daqif::DaqState state) noexcept
State
Observable states of the data acquisition process.
@ Completed
Completed DAQ.
@ NotScheduled
Before daq is acknowledged by dpm it remains in NotScheduled.
@ Scheduled
daq is acknowledged by dpm and is scheduled for merging (i.e.
@ Releasing
Releasing Data Product to receivers.
@ Aborted
Data acquisition has been aborted by user.
@ Merging
DAQ is being merged.
@ Stopping
Transitional state between Acquiring and Stopped.
@ AbortingMerging
Transitional state for aborting during merging.
@ Transferring
Input files are being transferred.
@ Acquiring
All data sources have reported data acquisition is in progress.
@ Stopped
All data sources have reported they have stopped acquiring data.
@ Starting
Transitional state between NotStarted and Acquiring when sources have not begun acquiring data yet.
@ AbortingAcquiring
Transitional state for aborting during acquisition.
@ NotStarted
Initial state of data acquisition.
Describes the full state and substate.
Contains declaration for Status and ObservableStatus.
Non observable status object that keeps stores status of data acquisition.
std::chrono::time_point< std::chrono::steady_clock > TimePoint
std::string result
Path to resulting data product.
std::vector< Alert > alerts
Active alerts.