21 using Seconds = std::chrono::duration<double, std::ratio<1>>;
25 status.setState(full_state.state);
26 status.setSubState(full_state.substate);
28 status.setResult(rhs.
result);
30 std::chrono::time_point_cast<Seconds>(rhs.
timestamp).time_since_epoch().count());
32 nlohmann::json j = rhs.
alerts;
33 status.setMessage(j.dump(2));
39 using Seconds = std::chrono::duration<double, std::ratio<1>>;
40 status.
id = rhs.getId();
41 status.
file_id = rhs.getFileId();
43 status.
result = rhs.getResult();
45 std::chrono::duration_cast<Status::TimePoint::duration>(Seconds(rhs.getTimestamp())));
49daqif::InternalDaqStatus&
operator<<(daqif::InternalDaqStatus& status,
Status const& rhs) {
50 nlohmann::json j = rhs;
51 status.setPayload(std::make_shared<daqif::Blob>(j.dump(2)));
56 std::string_view sv = AsStringView(*rhs.getPayload());
57 auto json = nlohmann::json::parse(std::begin(sv), std::end(sv));
58 status = json.get<
Status>();
62std::filesystem::space_info&
63operator<<(std::filesystem::space_info& space, daqif::StorageStatus
const& rhs) {
64 space.available = rhs.getAvailable();
65 space.capacity = rhs.getCapacity();
66 space.free = rhs.getFree();
70daqif::StorageStatus&
operator<<(daqif::StorageStatus& storage, std::filesystem::space_info& rhs) {
71 storage.setAvailable(rhs.available);
72 storage.setCapacity(rhs.capacity);
73 storage.setFree(rhs.free);
81 return {daqif::StateAcquiring, daqif::NotStarted};
83 return {daqif::StateAcquiring, daqif::Starting};
85 return {daqif::StateAcquiring, daqif::Acquiring};
87 return {daqif::StateAcquiring, daqif::Stopping};
89 return {daqif::StateAcquiring, daqif::Stopped};
91 return {daqif::StateAcquiring, daqif::Aborting};
94 return {daqif::StateMerging, daqif::NotScheduled};
96 return {daqif::StateMerging, daqif::Scheduled};
98 return {daqif::StateMerging, daqif::Collecting};
100 return {daqif::StateMerging, daqif::Merging};
102 return {daqif::StateMerging, daqif::Releasing};
104 return {daqif::StateMerging, daqif::Aborting};
107 return {daqif::StateCompleted, daqif::Completed};
109 return {daqif::StateCompleted, daqif::Aborted};
112 return {daqif::StateUndefined, daqif::Undefined};
119 switch (state.substate) {
120 case daqif::NotStarted:
122 case daqif::Starting:
124 case daqif::Acquiring:
126 case daqif::Stopping:
131 case daqif::NotScheduled:
133 case daqif::Scheduled:
135 case daqif::Collecting:
139 case daqif::Releasing:
142 case daqif::Completed:
145 case daqif::Aborting:
154 stderr,
"Invalid daqif::DaqSubState value {:d} (undefined behaviour)", state.substate);
160std::string_view
ToString(daqif::DaqState state)
noexcept {
161 using namespace std::string_view_literals;
163 case daqif::StateAcquiring:
164 return "StateAcquiring";
165 case daqif::StateMerging:
166 return "StateMerging";
167 case daqif::StateCompleted:
168 return "StateCompleted";
169 case daqif::DaqState::StateUndefined:
176std::string_view
ToString(daqif::DaqSubState state)
noexcept {
177 using namespace std::string_view_literals;
179 case daqif::DaqSubState::NotStarted:
181 case daqif::DaqSubState::Starting:
183 case daqif::DaqSubState::Acquiring:
185 case daqif::DaqSubState::Stopping:
187 case daqif::DaqSubState::Stopped:
189 case daqif::DaqSubState::Aborting:
191 case daqif::DaqSubState::Aborted:
193 case daqif::DaqSubState::NotScheduled:
194 return "NotScheduled";
195 case daqif::DaqSubState::Scheduled:
197 case daqif::DaqSubState::Collecting:
199 case daqif::DaqSubState::Merging:
201 case daqif::DaqSubState::Releasing:
203 case daqif::DaqSubState::Completed:
205 case daqif::DaqSubState::Undefined:
Declares JSON support for serialization.
Contains support functions for daqif.
Declares daq::State and related functions.
daqif::FullState MakeState(State state) noexcept
Converts daq::State to DaqSubstate.
std::string_view ToString(daqif::DaqState state) noexcept
std::ostream & operator<<(std::ostream &os, AsyncProcessIf const &proc)
Formats proc representation in the form [<pid>] <args>
bool HasError(Status const &status) 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.
@ Collecting
Input files are being collected.
@ 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.
@ 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::string result
Path to resulting data product.
std::vector< Alert > alerts
Active alerts.
std::chrono::time_point< std::chrono::system_clock > TimePoint
TimePoint timestamp
Timestamp of last update.