ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
state.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_common_libdaq
4  * @copyright 2022 ESO - European Southern Observatory
5  *
6  * @brief Declares `daq::State` and related functions.
7  */
8 #ifndef DAQ_STATE_HPP_
9 #define DAQ_STATE_HPP_
10 
11 #include <iosfwd>
12 
13 namespace daq {
14 
15 /**
16  * Observable states of the data acquisition process.
17  *
18  * Final states are either Completed* or Aborted*.
19  *
20  * life-cycle is fully sequential apart from Aborting and Aborted:
21  *
22  * The states implemented in OCM are:
23  *
24  * NotStarted -> Starting -> Acquiring -> Stopping -> Stopped -> <NotScheduled>
25  *
26  * and the remaining in DPM for executing the merging (handover is done in state NotScheduled):
27  *
28  * <NotScheduled> -> Scheduled -> Transferring -> Merging -> Releasing -> Completed*
29  *
30  * Each state apart from Completed may transition (optionally via Aborting) to Aborted*.
31  *
32  * Aborting -> Aborted*.
33  *
34  *
35  * Where the state
36  *
37  * @ingroup daq_common_libdaq
38  */
39 enum class State {
40  /**
41  * @name DAQ states handled by OCM.
42  */
43  /// @{
44  /**
45  * Initial state of data acquisition.
46  */
47  NotStarted = 0,
48  /**
49  * Transitional state between NotStarted and Acquiring when sources have not begun acquiring
50  * data yet.
51  */
52  Starting = 1,
53  /**
54  * All data sources have reported data acquisition is in progress.
55  */
56  Acquiring = 2,
57  /**
58  * Transitional state between Acquiring and Stopped.
59  */
60  Stopping = 3,
61  /**
62  * All data sources have reported they have stopped acquiring data.
63  */
64  Stopped = 4,
65 
66  /**
67  * Before daq is acknowledged by dpm it remains in NotScheduled.
68  *
69  * OCM may have attempted to schedule merging in this state so no more modifications are allowed
70  * from this point (e.g. updating keywords).
71  */
72  NotScheduled = 10,
73 
74  /**
75  * Transitional state for aborting during acquisition
76  */
77  AbortingAcquiring = 2001,
78  /// @}
79 
80  /***
81  * @name DAQ states that are handled by DPM.
82  */
83  /// @{
84  /**
85  * daq is acknowledged by dpm and is scheduled for merging (i.e. the daq is in the
86  * backlog).
87  */
88  Scheduled = 11,
89 
90  /**
91  * Input files are being transferred.
92  */
93  Transferring = 12,
94  /**
95  * DAQ is being merged.
96  */
97  Merging = 13,
98 
99  /**
100  * Releasing Data Product to receivers.
101  */
102  Releasing = 14,
103 
104  /**
105  * Transitional state for aborting during merging
106  */
107  AbortingMerging = 2010,
108  /// @}
109 
110  /***
111  * @name States common to OCM and DPM
112  */
113  /// @{
114  /**
115  * Data acquisition has been aborted by user.
116  */
117  Aborted = 2000,
118  /**
119  * Completed DAQ
120  */
121  Completed = 3000,
122  /// @}
123 };
124 
125 /**
126  * Prints state string representation to os.
127  *
128  * @ingroup daq_common_libdaq
129  */
130 std::ostream& operator<<(std::ostream& os, State state);
131 
132 /**
133  * Query whether @a state is in a final state.
134  *
135  * @returns true if @a state is Completed or Aborted.
136  * @returns false otherwise.
137  *
138  * @ingroup daq_common_libdaq
139  */
140 bool IsFinalState(State state) noexcept;
141 
142 /**
143  * Compares states and returns whether @a state1 occurs after @a state2. If states are the same it
144  * returns false.
145  *
146  * This is e.g. useful to decide when an await condition is fulfillled or when to reject a wait
147  * condition because will never occur.
148  *
149  * @returns true if @a state1 occurs after @a state2 in the DAQ life-cycle.
150  *
151  * @ingroup daq_common_libdaq
152  */
153 bool IsSubsequentState(State state1, State state2) noexcept;
154 
155 }
156 #endif // #ifndef DAQ_STATE_HPP_
daqif::DaqStatus & operator<<(daqif::DaqStatus &status, daq::Status const &rhs)
Convert daq::Status -> daqif::DaqStatus by populating from rhs.
Definition: conversion.cpp:18
bool IsSubsequentState(State state1, State state2) noexcept
Compares states and returns whether state1 occurs after state2.
Definition: state.cpp:26
State
Observable states of the data acquisition process.
Definition: state.hpp:39
@ 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.
bool IsFinalState(State state) noexcept
Query whether state is in a final state.
Definition: state.cpp:15