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>>(
"StartDaq",
115 std::string_view(
"start metadata acquisition"))
119 boost::future<void> StartAsync::StartPrim() {
120 return SendRequestAndCollectReplies<void>(
121 m_params.prim_sources.begin(),
122 m_params.prim_sources.end(),
123 [](
auto&) { return true; },
126 [
id = m_params.id](Source<PrimSource>& s) {
127 auto properties = std::make_shared<RecPropertiesImpl>();
128 properties->setId(id);
129 s.SetState(State::Starting, false);
130 return s.GetSource().GetRrClient().RecStart(properties);
133 [](AsyncOpParams params,
134 Source<PrimSource>& source,
135 boost::future<std::shared_ptr<recif::RecStatus>>&& fut) ->
void {
136 HandlePrimDaqReply<std::shared_ptr<recif::RecStatus>>(
"RecStart",
144 std::string_view(
"start primary data acquisition"))