rogue
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
rogue::interfaces::ZmqClient Class Reference

ZeroMQ client for Rogue control and update messaging. More...

#include <ZmqClient.h>

Inheritance diagram for rogue::interfaces::ZmqClient:
rogue::interfaces::ZmqClientWrap

Public Member Functions

 ZmqClient (const std::string &addr, uint16_t port, bool doString)
 Constructs a ZeroMQ client and connects sockets.
 
virtual ~ZmqClient ()
 Destroys client and stops background activity.
 
void setTimeout (uint32_t warnTime, uint32_t failTime=0)
 Sets request timeout behavior.
 
void setTimeout (uint32_t warnTime, bool failTime)=delete
 
void setTimeout (uint32_t warnTime, bool waitRetry, uint32_t maxRetries)=delete
 
std::string sendString (const std::string &path, const std::string &attr, const std::string &arg)
 Sends a string-mode request.
 
std::string getDisp (const std::string &path)
 Reads display-formatted value at a path (string mode).
 
void setDisp (const std::string &path, const std::string &value)
 Writes display-formatted value at a path (string mode).
 
std::string exec (const std::string &path, const std::string &arg="")
 Executes callable node at path (string mode).
 
std::string valueDisp (const std::string &path)
 Reads compact value display at a path (string mode).
 
boost::python::object send (boost::python::object data)
 Sends binary request payload and receives binary response.
 
virtual void doUpdate (boost::python::object data)
 Handles async update payloads received on subscriber socket.
 
void stop ()
 Stops client sockets and background thread.
 

Static Public Member Functions

static std::shared_ptr< rogue::interfaces::ZmqClientcreate (const std::string &addr, uint16_t port, bool doString)
 Creates a ZeroMQ client.
 
static void setup_python ()
 Registers Python bindings for this class.
 

Detailed Description

ZeroMQ client for Rogue control and update messaging.

ZmqClient connects to a ZmqServer endpoint and supports two operating modes selected by doString:

In binary mode, a background thread receives publish updates and dispatches them to doUpdate().

Definition at line 50 of file ZmqClient.h.

Constructor & Destructor Documentation

◆ ZmqClient()

rogue::interfaces::ZmqClient::ZmqClient ( const std::string &  addr,
uint16_t  port,
bool  doString 
)

Constructs a ZeroMQ client and connects sockets.

This constructor is a low-level C++ allocation path. Prefer create() when shared ownership or Python exposure is required.

Parameters
addrServer bind address or host.
portBase server port.
doStringtrue for string request mode, false for binary mode.

Definition at line 113 of file ZmqClient.cpp.

◆ ~ZmqClient()

rogue::interfaces::ZmqClient::~ZmqClient ( )
virtual

Destroys client and stops background activity.

Definition at line 212 of file ZmqClient.cpp.

Member Function Documentation

◆ create()

rogue::interfaces::ZmqClientPtr rogue::interfaces::ZmqClient::create ( const std::string &  addr,
uint16_t  port,
bool  doString 
)
static

Creates a ZeroMQ client.

Parameter semantics are identical to the constructor; see ZmqClient() for socket setup behavior details. This static factory is the preferred construction path when the object is shared across Rogue graph connections or exposed to Python. It returns std::shared_ptr ownership compatible with Rogue pointer typedefs.

Parameters
addrServer bind address or host.
portBase server port.
doStringtrue for string request mode, false for binary mode.
Returns
Shared pointer to the created client.

Definition at line 90 of file ZmqClient.cpp.

◆ doUpdate()

void rogue::interfaces::ZmqClient::doUpdate ( boost::python::object  data)
virtual

Handles async update payloads received on subscriber socket.

Parameters
dataUpdate payload as Python object.

Reimplemented in rogue::interfaces::ZmqClientWrap.

Definition at line 428 of file ZmqClient.cpp.

◆ exec()

std::string rogue::interfaces::ZmqClient::exec ( const std::string &  path,
const std::string &  arg = "" 
)

Executes callable node at path (string mode).

Parameters
pathRogue node path.
argOptional argument string.
Returns
Callable result as string.

Definition at line 324 of file ZmqClient.cpp.

◆ getDisp()

std::string rogue::interfaces::ZmqClient::getDisp ( const std::string &  path)

Reads display-formatted value at a path (string mode).

Parameters
pathRogue node path.
Returns
Display-formatted value.

Definition at line 316 of file ZmqClient.cpp.

◆ send()

boost::python::object rogue::interfaces::ZmqClient::send ( boost::python::object  data)

Sends binary request payload and receives binary response.

Parameters
dataPython object exposing a readable buffer.
Returns
Response bytes as a Python bytes-like object.

Definition at line 334 of file ZmqClient.cpp.

◆ sendString()

std::string rogue::interfaces::ZmqClient::sendString ( const std::string &  path,
const std::string &  attr,
const std::string &  arg 
)

Sends a string-mode request.

Parameters
pathRogue node path.
attrAttribute or operation name.
argOptional argument string.
Returns
Server response string.

Definition at line 266 of file ZmqClient.cpp.

◆ setDisp()

void rogue::interfaces::ZmqClient::setDisp ( const std::string &  path,
const std::string &  value 
)

Writes display-formatted value at a path (string mode).

Parameters
pathRogue node path.
valueValue string to apply.

Definition at line 320 of file ZmqClient.cpp.

◆ setTimeout() [1/3]

void rogue::interfaces::ZmqClient::setTimeout ( uint32_t  warnTime,
bool  failTime 
)
delete

◆ setTimeout() [2/3]

void rogue::interfaces::ZmqClient::setTimeout ( uint32_t  warnTime,
bool  waitRetry,
uint32_t  maxRetries 
)
delete

◆ setTimeout() [3/3]

void rogue::interfaces::ZmqClient::setTimeout ( uint32_t  warnTime,
uint32_t  failTime = 0 
)

Sets request timeout behavior.

The recv loop in send() / sendString() wakes every warnTime milliseconds; on each wake it logs a "still waiting" warning and keeps waiting until the accumulated wait reaches failTime, at which point it throws rogue::GeneralError. failTime == 0 (default) installs no deadline and retries forever, preserving the historic contract that downstream callers (notably pysmurf) rely on. Use failTime == warnTime to fail on the first timeout.

Parameters
warnTimeWarn/poll period in milliseconds (ZMQ_RCVTIMEO). Must be greater than 0; a value of 0 throws rogue::GeneralError.
failTimeAbsolute wait deadline in milliseconds. 0 (default) means no deadline (retry forever).

Definition at line 244 of file ZmqClient.cpp.

◆ setup_python()

void rogue::interfaces::ZmqClient::setup_python ( )
static

Registers Python bindings for this class.

Setup class in python.

Definition at line 96 of file ZmqClient.cpp.

◆ stop()

void rogue::interfaces::ZmqClient::stop ( )

Stops client sockets and background thread.

Definition at line 216 of file ZmqClient.cpp.

◆ valueDisp()

std::string rogue::interfaces::ZmqClient::valueDisp ( const std::string &  path)

Reads compact value display at a path (string mode).

Parameters
pathRogue node path.
Returns
Value display string.

Definition at line 328 of file ZmqClient.cpp.


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