10 #include <Metadaqif.hpp>
11 #include <fmt/format.h>
12 #include <fmt/ostream.h>
13 #include <log4cplus/loggingmacros.h>
14 #include <boost/assert.hpp>
20 class RecPropertiesImpl :
public recif::RecProperties {
22 double getAbsTime()
const override {
25 void setAbsTime(
double abs_time)
override {
28 std::string getId()
const override {
31 void setId(
const std::string&
id)
override {
35 std::string getInfo()
const override {
38 void setInfo(
const std::string& info)
override {
41 std::vector<std::string> getPublishers()
const override {
44 void setPublishers(
const std::vector<std::string>& publishers)
override {
46 bool hasKey()
const override {
49 std::unique_ptr<recif::RecProperties> cloneKey()
const override {
50 throw std::runtime_error(
"not clonable");
52 std::unique_ptr<recif::RecProperties> clone()
const override {
53 throw std::runtime_error(
"not clonable");
55 bool keyEquals(
const recif::RecProperties& other)
const override {
73 [
this](boost::future<void>&& f) -> boost::future<void> {
75 if (f.has_exception()) {
76 LOG4CPLUS_INFO(m_params.logger,
77 fmt::format(
"{}: StartAsync: StartAsync metadaq "
78 "failed. Will not start primary data acquisition.",
90 boost::future<void> StartAsync::StartMeta() {
91 return SendRequestAndCollectReplies<void>(
92 m_params.meta_sources.begin(),
93 m_params.meta_sources.end(),
95 [](
auto&) { return true; },
99 s.SetState(State::Starting, false);
100 return s.GetSource().GetRrClient().StartDaq(id);
105 [](AsyncOpParams params,
107 boost::future<std::shared_ptr<metadaqif::DaqReply>>&& fut) ->
void {
108 HandleMetaDaqReply<std::shared_ptr<metadaqif::DaqReply>>(
"StartDaq",
116 std::string_view(
"StartDaq() (start metadata acquisition)"))
120 boost::future<void> StartAsync::StartPrim() {
121 return SendRequestAndCollectReplies<void>(
122 m_params.prim_sources.begin(),
123 m_params.prim_sources.end(),
124 [](
auto&) { return true; },
127 [
id = m_params.id](Source<PrimSource>& s) {
128 auto& client = s.GetSource().GetRrClient();
129 #if defined(UNIT_TEST)
134 auto properties = std::make_shared<RecPropertiesImpl>();
137 auto mal = client.getMal();
138 BOOST_ASSERT_MSG(mal,
"MAL RR client returned invalid MAL pointer");
139 auto properties = mal->createDataEntity<recif::RecProperties>();
141 *properties = RecPropertiesImpl();
143 properties->setId(id);
144 s.SetState(State::Starting, false);
145 return client.RecStart(properties);
148 [](AsyncOpParams params,
149 Source<PrimSource>& source,
150 boost::future<std::shared_ptr<recif::RecStatus>>&& fut) ->
void {
151 HandlePrimDaqReply<std::shared_ptr<recif::RecStatus>>(
"RecStart",
159 std::string_view(
"RecStart() (start primary data acquisition)"))
Declares daq::State and related functions.
void UnwrapVoidReplies(boost::future< std::vector< boost::future< void >>> futures)
Unwrap futures to extract errors.
Contains declaration for the StartAsync operation.
Simple class that holds the source and associated state.
Parameters required for each async operation.
rad::IoExecutor & executor
StartAsync(AsyncOpParams params) noexcept
boost::future< void > Initiate()
Initiates operation that starts metadata acquisition.
Contains declaration for the async op utilities.