ifw-daq  1.0.0
IFW Data Acquisition modules
asyncOpParams.hpp
Go to the documentation of this file.
1 #ifndef DAQ_OP_ASYNC_OP_PARAMS_HPP_
2 #define DAQ_OP_ASYNC_OP_PARAMS_HPP_
3 
4 #include <boost/asio/io_context.hpp>
5 #include <log4cplus/logger.h>
6 
7 #include <rad/ioExecutor.hpp>
8 
9 #include "../status.hpp"
10 #include "../eventLog.hpp"
11 #include "../pendingReplies.hpp"
12 #include "../source.hpp"
13 #include "../state.hpp"
14 #include "../utility.hpp"
15 
16 namespace daq::op {
17 
18 /**
19  * Parameters required for each async operation.
20  *
21  * Caller is responsible for keeping objects alive for the duration of the operation.
22  */
23 struct AsyncOpParams {
24  AsyncOpParams(ObservableStatus const& status_arg,
25  ObservableEventLog& event_log_arg,
26  rad::IoExecutor& executor_arg,
27  log4cplus::Logger& logger_arg,
28  std::string const& id_arg,
29  PendingReplies& pending_replies_arg,
30  std::vector<Source<PrimSource>>& prim_sources_arg,
31  std::vector<Source<MetaSource>>& meta_sources_arg)
32  : status(status_arg)
33  , event_log(event_log_arg)
34  , executor(executor_arg)
35  , logger(logger_arg)
36  , id(id_arg)
37  , pending_replies(pending_replies_arg)
38  , prim_sources(prim_sources_arg)
39  , meta_sources(meta_sources_arg) {
40  }
41  AsyncOpParams(AsyncOpParams const&) = default;
43 
44  /**
45  * Async operations should not modify status directly
46  * DaqController does that.
47  */
51  log4cplus::Logger& logger;
52  std::string const& id;
54  std::vector<Source<PrimSource>>& prim_sources; ///< Note: Consider vector immutable!
55  std::vector<Source<MetaSource>>& meta_sources; ///< Note: Consider vector immutable!a
56 };
57 
58 /**
59  * Await specific parameters that is not provided with AsyncOpParams.
60  *
61  * @important The clients provided must be configured with a reply timeout that takes the wait
62  * timeout into account, otherwise MAL will time out before reply is sent.
63  */
64 struct AwaitOpParams {
65  using Duration = std::chrono::milliseconds;
66  AwaitOpParams(AsyncOpParams common_arg, AwaitOpParams::Duration wait_interval_arg) noexcept
67  : common(common_arg), wait_interval(wait_interval_arg) {
68  }
69  AwaitOpParams(AwaitOpParams const&) = default;
71 
73 
74  /**
75  * Total amount of time to wait for condition to be fulfilled.
76  */
78 };
79 
80 } // namespace daq::op
81 
82 #endif // #ifndef DAQ_OP_ASYNC_OP_PARAMS_HPP_
daq::op::AsyncOpParams::prim_sources
std::vector< Source< PrimSource > > & prim_sources
Note: Consider vector immutable!
Definition: asyncOpParams.hpp:54
daq::op::AsyncOpParams::logger
log4cplus::Logger & logger
Definition: asyncOpParams.hpp:51
daq::op::AsyncOpParams::pending_replies
PendingReplies & pending_replies
Definition: asyncOpParams.hpp:53
daq::op::AsyncOpParams::AsyncOpParams
AsyncOpParams(AsyncOpParams const &)=default
ioExecutor.hpp
daq::op::AsyncOpParams::meta_sources
std::vector< Source< MetaSource > > & meta_sources
Note: Consider vector immutable!a.
Definition: asyncOpParams.hpp:55
daq::op::AwaitOpParams::AwaitOpParams
AwaitOpParams(AwaitOpParams &&)=default
daq::PendingReplies
Simple class that allows you to keep track of how many replies are pending.
Definition: pendingReplies.hpp:58
rad::IoExecutor
Adapts boost::asio::io_context into a compatible boost::thread Executor type.
Definition: ioExecutor.hpp:12
daq::op::AsyncOpParams::event_log
ObservableEventLog & event_log
Definition: asyncOpParams.hpp:49
daq::Source
Simple class that holds the source and associated state.
Definition: source.hpp:29
daq::ObservableStatus
Stores data acquisition status and allows subscription to status changes.
Definition: status.hpp:68
daq::op::AwaitOpParams
Await specific parameters that is not provided with AsyncOpParams.
Definition: asyncOpParams.hpp:64
daq::op::AwaitOpParams::AwaitOpParams
AwaitOpParams(AsyncOpParams common_arg, AwaitOpParams::Duration wait_interval_arg) noexcept
Definition: asyncOpParams.hpp:66
daq::op::AwaitOpParams::Duration
std::chrono::milliseconds Duration
Definition: asyncOpParams.hpp:65
daq::op
Definition: abort.hpp:19
daq::op::AsyncOpParams::executor
rad::IoExecutor & executor
Definition: asyncOpParams.hpp:50
daq::op::AsyncOpParams::AsyncOpParams
AsyncOpParams(ObservableStatus const &status_arg, ObservableEventLog &event_log_arg, rad::IoExecutor &executor_arg, log4cplus::Logger &logger_arg, std::string const &id_arg, PendingReplies &pending_replies_arg, std::vector< Source< PrimSource >> &prim_sources_arg, std::vector< Source< MetaSource >> &meta_sources_arg)
Definition: asyncOpParams.hpp:24
daq::op::AsyncOpParams::id
std::string const & id
Definition: asyncOpParams.hpp:52
daq::op::AsyncOpParams::status
ObservableStatus const & status
Async operations should not modify status directly DaqController does that.
Definition: asyncOpParams.hpp:48
daq::op::AwaitOpParams::AwaitOpParams
AwaitOpParams(AwaitOpParams const &)=default
daq::op::AwaitOpParams::common
AsyncOpParams common
Definition: asyncOpParams.hpp:72
daq::op::AsyncOpParams
Parameters required for each async operation.
Definition: asyncOpParams.hpp:23
daq::ObservableEventLog
Stores data acquisition status and allows subscription to status changes.
Definition: eventLog.hpp:107
daq::op::AwaitOpParams::wait_interval
Duration wait_interval
Total amount of time to wait for condition to be fulfilled.
Definition: asyncOpParams.hpp:77
daq::op::AsyncOpParams::AsyncOpParams
AsyncOpParams(AsyncOpParams &&)=default