DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
daphne::zmq::ControlClient Class Reference

Thin RAII wrapper that sends Configure* protobuf requests and returns the corresponding responses. More...

#include <ControlClient.hpp>

Public Types

using Milliseconds = std::chrono::milliseconds
 

Public Member Functions

 ControlClient (zmq::context_t &ctx, std::string_view ip, uint16_t port, Milliseconds timeout=Milliseconds{500})
 
daphnemodules::ConfigureResponse configure (const daphnemodules::ConfigureRequest &req)
 
daphnemodules::ConfigureCLKsResponse configure_clks (const daphnemodules::ConfigureCLKsRequest &req)
 

Private Attributes

zmq::socket_t socket_
 

Detailed Description

Thin RAII wrapper that sends Configure* protobuf requests and returns the corresponding responses.

Lifetime:

  • holds a ref to the external ZeroMQ context (no duplication)
  • owns a DEALER/REQ socket

Definition at line 22 of file ControlClient.hpp.

Member Typedef Documentation

◆ Milliseconds

using daphne::zmq::ControlClient::Milliseconds = std::chrono::milliseconds

Definition at line 25 of file ControlClient.hpp.

Constructor & Destructor Documentation

◆ ControlClient()

daphne::zmq::ControlClient::ControlClient ( zmq::context_t & ctx,
std::string_view ip,
uint16_t port,
Milliseconds timeout = Milliseconds{500} )

Definition at line 42 of file ControlClient.cpp.

46 : socket_(ctx, zmq::socket_type::req)
47{
48 socket_.set(zmq::sockopt::rcvtimeo, static_cast<int>(timeout.count()));
49 socket_.set(zmq::sockopt::sndtimeo, static_cast<int>(timeout.count()));
50 socket_.connect(fmt::format("tcp://{}:{}", ip, port));
51}

Member Function Documentation

◆ configure()

daphnemodules::ConfigureResponse daphne::zmq::ControlClient::configure ( const daphnemodules::ConfigureRequest & req)

Send an already-filled ConfigureRequest and wait for reply.

Definition at line 56 of file ControlClient.cpp.

57{
58 auto bytes = make_envelope_bytes(daphnemodules::CONFIGURE_FE, req);
59 socket_.send(zmq::buffer(bytes), zmq::send_flags::none);
60
61 zmq::message_t reply;
62 socket_.recv(reply, zmq::recv_flags::none);
63
64 return parse_response<daphnemodules::ConfigureResponse>(
65 reply, daphnemodules::CONFIGURE_FE);
66}

◆ configure_clks()

daphnemodules::ConfigureCLKsResponse daphne::zmq::ControlClient::configure_clks ( const daphnemodules::ConfigureCLKsRequest & req)

Same for ConfigureCLKsRequest

Definition at line 69 of file ControlClient.cpp.

71{
72 auto bytes = make_envelope_bytes(daphnemodules::CONFIGURE_CLKS, req);
73 socket_.send(zmq::buffer(bytes), zmq::send_flags::none);
74
75 zmq::message_t reply;
76 socket_.recv(reply, zmq::recv_flags::none);
77
78 return parse_response<daphnemodules::ConfigureCLKsResponse>(
79 reply, daphnemodules::CONFIGURE_CLKS);
80}

Member Data Documentation

◆ socket_

zmq::socket_t daphne::zmq::ControlClient::socket_
private

Definition at line 41 of file ControlClient.hpp.


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