10 #include <Metadaqif.hpp>
11 #include <fmt/format.h>
12 #include <fmt/ostream.h>
13 #include <log4cplus/loggingmacros.h>
19 class RecPropertiesImpl :
public recif::RecProperties {
21 double getAbsTime()
const override {
24 void setAbsTime(
double abs_time)
override {
27 std::string getId()
const override {
30 void setId(
const std::string&
id)
override {
34 std::string getInfo()
const override {
37 void setInfo(
const std::string& info)
override {
40 std::vector<std::string> getPublishers()
const override {
43 void setPublishers(
const std::vector<std::string>& publishers)
override {
45 bool hasKey()
const override {
48 std::unique_ptr<recif::RecProperties> cloneKey()
const override {
49 throw std::runtime_error(
"not clonable");
51 std::unique_ptr<recif::RecProperties> clone()
const override {
52 throw std::runtime_error(
"not clonable");
54 bool keyEquals(
const recif::RecProperties& other)
const override {
72 [
this](boost::future<void>&& f) -> boost::future<void> {
74 if (f.has_exception()) {
75 LOG4CPLUS_INFO(m_params.logger,
76 fmt::format(
"{}: StartAsync: StartAsync metadaq "
77 "failed. Will not start primary data acquisition.",
89 boost::future<void> StartAsync::StartMeta() {
90 return SendRequestAndCollectReplies<void>(
91 m_params.meta_sources.begin(),
92 m_params.meta_sources.end(),
94 [](
auto&) { return true; },
98 s.SetState(State::Starting, false);
99 return s.GetSource().GetRrClient().StartDaq(id);
104 [](AsyncOpParams params,
106 boost::future<std::shared_ptr<metadaqif::DaqReply>>&& fut) ->
void {
107 HandleMetaDaqReply<std::shared_ptr<metadaqif::DaqReply>>(State::Starting,
114 std::string_view(
"start metadata acquisition"))
118 boost::future<void> StartAsync::StartPrim() {
119 return SendRequestAndCollectReplies<void>(
120 m_params.prim_sources.begin(),
121 m_params.prim_sources.end(),
122 [](
auto&) { return true; },
125 [
id = m_params.id](Source<PrimSource>& s) {
126 auto properties = std::make_shared<RecPropertiesImpl>();
127 properties->setId(id);
128 s.SetState(State::Starting, false);
129 return s.GetSource().GetRrClient().RecStart(properties);
132 [](AsyncOpParams params,
133 Source<PrimSource>& source,
134 boost::future<std::shared_ptr<recif::RecStatus>>&& fut) ->
void {
135 HandlePrimDaqReply<std::shared_ptr<recif::RecStatus>>(State::Starting,
142 std::string_view(
"start primary data acquisition"))