DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::wibmod::WIBCommon Class Reference

The WIBCommon class defines convenience methods for using the ZeroMQ and protobuf communication protocol to the WIB. More...

#include <WIBCommon.hpp>

Public Member Functions

 WIBCommon (const std::string &wib_addr)
 
 ~WIBCommon ()
 
template<class R , class C >
void send_command (const C &msg, R &repl)
 

Private Attributes

zmq::context_t context
 
zmq::socket_t socket
 

Detailed Description

The WIBCommon class defines convenience methods for using the ZeroMQ and protobuf communication protocol to the WIB.

Definition at line 28 of file WIBCommon.hpp.

Constructor & Destructor Documentation

◆ WIBCommon()

dunedaq::wibmod::WIBCommon::WIBCommon ( const std::string & wib_addr)

Definition at line 20 of file WIBCommon.cpp.

20 :
21 context(1),
22 socket(context, ZMQ_REQ)
23{
24 socket.connect(wib_addr); // tcp://192.168.121.*:1234
25 TLOG_DEBUG(0) << wib_addr << " Connected!";
26}
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ ~WIBCommon()

dunedaq::wibmod::WIBCommon::~WIBCommon ( )

Definition at line 28 of file WIBCommon.cpp.

29{
30 socket.close();
31}

Member Function Documentation

◆ send_command()

template<class R , class C >
void dunedaq::wibmod::WIBCommon::send_command ( const C & msg,
R & repl )

Definition at line 49 of file WIBCommon.hpp.

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);
60
61 zmq::message_t reply;
62 socket.recv(&reply);
63
64 std::string reply_str(static_cast<char*>(reply.data()), reply.size());
65 repl.ParseFromString(reply_str);
66}
::google::protobuf::Any * mutable_cmd()
Definition wib.pb.h:7195

Member Data Documentation

◆ context

zmq::context_t dunedaq::wibmod::WIBCommon::context
private

Definition at line 41 of file WIBCommon.hpp.

◆ socket

zmq::socket_t dunedaq::wibmod::WIBCommon::socket
private

Definition at line 43 of file WIBCommon.hpp.


The documentation for this class was generated from the following files: