plestylib.service.tcp_ip_client#

Classes#

DeviceTCPIPClient

ZeroMQ-based client for remote device control.

Module Contents#

class plestylib.service.tcp_ip_client.DeviceTCPIPClient(address='tcp://localhost:5555', timeout=5000)#

ZeroMQ-based client for remote device control.

This client provides a transparent interface to a remote device server. Methods can be invoked as if the device were local.

Features:
  • Standard query/write interface

  • Arbitrary remote function calls

  • Automatic method discovery and binding

  • Timeout support

  • Structured error handling

Initialize the device client.

Parameters:
  • address – Server address.

  • timeout – Receive timeout in milliseconds.

ctx#
socket#
_description#
_send(payload)#

Send a request to the server and wait for response.

Parameters:

payload – Dictionary payload.

Returns:

Result from server.

Return type:

Any

Raises:
  • RuntimeError – If server returns an error.

  • TimeoutError – If no response is received.

query(param, timeout=None)#

Query a device parameter.

Parameters:
  • param – Parameter name.

  • timeout – Optional timeout in seconds (server-side).

Returns:

Parameter value.

Return type:

Any

write(param, value, timeout=None)#

Write a device parameter.

Parameters:
  • param – Parameter name.

  • value – Value to set.

  • timeout – Optional timeout in seconds (server-side).

Returns:

Result from device.

Return type:

Any

call(func, *args, timeout=None, **kwargs)#

Call a remote device function.

Parameters:
  • func – Function name.

  • args – Positional arguments.

  • timeout – Optional timeout in seconds (server-side).

  • kwargs – Keyword arguments.

Returns:

Function result.

Return type:

Any

describe()#

Retrieve available device methods from server.

Returns:

Device description.

Return type:

dict

_build_methods()#

Dynamically attach remote methods as local methods.

_make_proxy(name)#

Create a proxy method for a remote function.

Parameters:

name – Function name.

Returns:

Proxy method.

Return type:

callable