ifw-daq  1.0.0
IFW Data Acquisition modules
state.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_ocm_libdaq
4  * @copyright 2021 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 <ostream>
12 
13 namespace daq {
14 
15 /**
16  * Observable states of the data acquisition process.
17  *
18  * Note: This does not yet include the separate states for creating the data product.
19  *
20  * Daq can end up in either Stopped or Aborted. At this point it is not possible to
21  * start it again.
22  * @verbatim
23  * Init
24  * |
25  * | +——————————+ +—————————+ +—————————+ +—————————+ +—————————+
26  * +—>+NotStarted+—————>|Starting +————>|Acquiring|————>|Stopping |———>|Stopped |
27  * +————+—————+ +————+————+ +—————————+ +—————————+ +—————————+
28  * | | | |
29  * | | | | +—————————+
30  * +————————————————>+——————————————>+——————————————>+————————>|Aborting |
31  * +—————————+
32  * |
33  * +
34  * +—————————+
35  * |Aborted |
36  * +—————————+
37  *
38  * @endverbatim
39  * @ingroup daq_ocm_libdaq
40  */
41 enum class State {
42  /**
43  * Initial state of data acquisition.
44  */
45  NotStarted = 0,
46  /**
47  * Transitional state between NotStarted and Acquiring when sources have not begun acquiring
48  * data yet.
49  */
50  Starting = 1,
51  /**
52  * All data sources have reported data acquisition is in progress.
53  */
54  Acquiring = 2,
55  /**
56  * Transitional state between Acquiring and Stopped.
57  */
58  Stopping = 3,
59  /**
60  * All data sources have reported they have stopped acquiring data.
61  */
62  Stopped = 4,
63 
64 
65  /**
66  * Transitional state from previous states to Aborted.
67  */
68  Aborting = 100,
69  /**
70  * Data acquisition has been aborted by user.
71  */
72  Aborted = 101,
73 };
74 
75 /**
76  * Prints state string representation to os.
77  *
78  * @ingroup daq_ocm_libdaq
79  */
80 std::ostream& operator<<(std::ostream& os, State state);
81 
82 /**
83  * Query whether @a state is in a final state.
84  *
85  * @returns true if @a state is Stopped or Aborted.
86  * @returns false otherwise.
87  *
88  * @ingroup daq_ocm_libdaq
89  */
90 bool IsFinalState(State state) noexcept;
91 
92 /**
93  * Compares states and returns whether @a state occurs after @a after. If states are the same it returns
94  * false.
95  *
96  * This is e.g. useful to decide when an await condition is fulfillled or when to reject a wait
97  * condition because will never occur.
98  *
99  * @returns true if @a state comes after @a after in the DAQ life-cycle.
100  *
101  * @ingroup daq_ocm_libdaq
102  */
103 bool IsSubsequentState(State state, State after) noexcept;
104 }
105 #endif // #ifndef DAQ_STATE_HPP_
daq::State
State
Observable states of the data acquisition process.
Definition: state.hpp:41
daq::IsFinalState
bool IsFinalState(State state) noexcept
Query whether state is in a final state.
Definition: state.cpp:14
daq
Definition: daqController.cpp:18
daq::IsSubsequentState
bool IsSubsequentState(State state, State after) noexcept
Compares states and returns whether state occurs after after.
Definition: state.cpp:25
daq::operator<<
std::ostream & operator<<(std::ostream &os, DaqController const &daq)
Definition: daqController.cpp:49
daq::State::NotStarted
@ NotStarted
Initial state of data acquisition.