17 std::ostream&
operator<<(std::ostream& os, std::shared_ptr<ocmif::DaqStatus>
const& s) {
18 os << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
20 <<
" id: " << s->getId() <<
"\n"
21 <<
" state: \"" <<
ToString(s->getState()) <<
"\"\n"
22 <<
" substate: \"" <<
ToString(s->getSubState()) <<
"\"\n"
23 <<
" error: \"" << (s->getError() ?
"true" :
"false") <<
"\n"
24 <<
" timestamp: " << s->getTimestamp();
30 std::ostream&
operator<<(std::ostream& os, std::shared_ptr<ocmif::DaqReply>
const& s) {
32 <<
" id: " << s->getId() <<
"\n"
33 <<
" error: " << (s->getError() ?
"true" :
"false") <<
"\n";
37 std::ostream&
operator<<(std::ostream& os, std::shared_ptr<ocmif::AwaitDaqReply>
const& s) {
38 os <<
"AwaitDaqReply:\n"
39 <<
" timeout: " << (s->getTimeout() ?
"true" :
"false") <<
"\n"
40 <<
" status: " << s->getStatus() <<
"\n";
44 std::ostream&
operator<<(std::ostream& os, std::vector<std::shared_ptr<ocmif::DaqStatus>>
const& vec) {
45 for (
auto const& s: vec) {
54 os << std::setprecision(std::numeric_limits<long double>::digits10 + 1);
66 << (s.t->getError() ?
"true" :
"false")
69 << s.t->getTimestamp()
76 operator<<(std::ostream& os,
JsonPrint<std::vector<std::shared_ptr<ocmif::DaqStatus>>>
const& vec) {
79 for (
auto const& s : vec.t) {
82 if (num < vec.t.size()) {
93 << s.t->getId() <<
"\",\n"
95 << (s.t->getError() ?
"true" :
"false") <<
"\n";
104 << (s.t->getTimeout() ?
"true" :
"false") <<
",\n"
113 os <<
"\"" << s.
t <<
"\"";
121 return std::string();
127 return "[<options>] <logger> <level>";
131 ::ocmif::OcmDaqSync& daq_cmds,
132 boost::program_options::variables_map& vm,
133 std::vector<std::string>& opts) {
135 if (opts.size() != 3) {
136 std::cerr <<
"setloglevel requires `<logger>` and <level>` arguments\n";
137 throw std::invalid_argument(
"Missing required arguments");
139 auto log_info =
m_args.
mal->createDataEntity<stdif::LogInfo>();
140 log_info->setLogger(opts[1]);
141 log_info->setLevel(opts[2]);
142 auto reply = std_cmds.SetLogLevel(log_info);
146 std::cout <<
"Reply: " << reply << std::endl;
151 namespace po = boost::program_options;
152 opt.add_options()(
"id", po::value<std::string>(&
m_id),
"data acquisition identifer")(
153 "prefix", po::value<std::string>(&
m_prefix),
"data product prefix")(
154 "properties", po::value<std::string>(&
m_properties),
"JSON properties");
159 return "[<options>] <primary-sources> <metadata-sources>";
163 ::ocmif::OcmDaqSync& daq_cmds,
164 boost::program_options::variables_map& vm,
165 std::vector<std::string>& opts) {
167 if (opts.size() != 3) {
168 std::cerr <<
"start daq requires the `<primary-sources>` and <metadata-sources>` arguments\n";
169 throw std::invalid_argument(
"Missing required arguments");
176 std::cout <<
"Reply: " << reply << std::endl;
181 namespace po = boost::program_options;
185 return "[<options>] <id> <keywords>";
189 ::ocmif::OcmDaqSync& daq_cmds,
190 boost::program_options::variables_map& vm,
191 std::vector<std::string>& opts) {
193 if (opts.size() != 3) {
194 std::cerr <<
"UpdateKeywords requires the `<id>` and <keywords>` arguments\n";
195 throw std::invalid_argument(
"Missing required arguments");
197 auto reply = daq_cmds.UpdateKeywords(opts[1], opts[2]);
201 std::cout <<
"Reply: " << reply << std::endl;
207 namespace po = boost::program_options;
211 return "[<options>] <id> <state> <substate> <timeout[s]>";
215 ::ocmif::OcmDaqSync& daq_cmds,
216 boost::program_options::variables_map& vm,
217 std::vector<std::string>& opts) {
219 if (opts.size() != 5) {
220 std::cerr <<
"AwaitDaqState requires the `<id>`, `<state>`, `<substate>` and <timeout>` "
222 throw std::invalid_argument(
"Missing required arguments");
224 auto state = ocmif::FromString<ocmif::DaqState>(opts[2]);
225 auto substate = ocmif::FromString<ocmif::DaqSubState>(opts[3]);
226 double timeout = std::stod(opts[4]);
227 auto reply = daq_cmds.AwaitDaqState(opts[1], state, substate, timeout);
231 std::cout <<
"Reply: " << reply << std::endl;