DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
wibmod
src
wibmod
WIBCommon.hpp
Go to the documentation of this file.
1
10
11
#ifndef WIBMOD_INCLUDE_WIBMOD_WIBCOMMON_HPP_
12
#define WIBMOD_INCLUDE_WIBMOD_WIBCOMMON_HPP_
13
14
#include "
logging/Logging.hpp
"
15
16
#include "zmq.hpp"
17
#include "
wib.pb.h
"
18
19
#include <string>
20
21
namespace
dunedaq
{
22
namespace
wibmod
{
23
28
class
WIBCommon
29
{
30
public
:
31
32
WIBCommon
(
const
std::string &wib_addr);
33
34
~WIBCommon
();
35
36
template
<
class
R,
class
C>
37
void
send_command
(
const
C &msg, R &repl);
38
39
private
:
40
41
zmq::context_t
context
;
42
43
zmq::socket_t
socket
;
44
45
};
46
47
template
<
class
R,
class
C>
48
void
49
WIBCommon::send_command
(
const
C &msg, R &repl)
50
{
51
wib::Command
command;
52
command.
mutable_cmd
()->PackFrom(msg);
53
54
std::string cmd_str;
55
command.SerializeToString(&cmd_str);
56
57
zmq::message_t request(cmd_str.size());
58
memcpy(
static_cast<
void
*
>
(request.data()), cmd_str.c_str(), cmd_str.size());
59
socket
.send(request, zmq::send_flags::none);
60
61
zmq::message_t reply;
62
auto
res =
socket
.recv(reply);
63
TLOG_DEBUG
(12) <<
"Recv res="
<< res.value_or(0);
64
65
std::string reply_str(
static_cast<
char
*
>
(reply.data()), reply.size());
66
repl.ParseFromString(reply_str);
67
}
68
69
}
// namespace wibmod
70
}
// namespace dunedaq
71
72
#endif
// WIBMOD_INCLUDE_WIBMOD_WIBCOMMON_HPP_
dunedaq::wibmod::WIBCommon::context
zmq::context_t context
Definition
WIBCommon.hpp:41
dunedaq::wibmod::WIBCommon::~WIBCommon
~WIBCommon()
Definition
WIBCommon.cpp:28
dunedaq::wibmod::WIBCommon::socket
zmq::socket_t socket
Definition
WIBCommon.hpp:43
dunedaq::wibmod::WIBCommon::WIBCommon
WIBCommon(const std::string &wib_addr)
Definition
WIBCommon.cpp:20
dunedaq::wibmod::WIBCommon::send_command
void send_command(const C &msg, R &repl)
Definition
WIBCommon.hpp:49
wib::Command
Definition
wib.pb.h:184
wib::Command::mutable_cmd
::google::protobuf::Any * mutable_cmd()
Definition
wib.pb.h:7195
Logging.hpp
TLOG_DEBUG
#define TLOG_DEBUG(lvl,...)
Definition
Logging.hpp:112
dunedaq::wibmod
Definition
WIBCommon.cpp:18
dunedaq
Including Qt Headers.
Definition
module.cpp:16
wib.pb.h
Generated on
for DUNE-DAQ by
1.17.0