Program#

class rb_sdk.rb_sdk_cpp.RBProgramSDK(*args, **kwargs)#

Bases: RBBaseSDK

alarm(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, title: str, content: str, robot_model: str, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#

Publishes a program dialog alarm.

Parameters:
  • title – Dialog title. Falls back to “No Title” when empty.

  • content – Dialog content.

  • robot_model – Name of the robot model.

  • flow_manager_args – Optional PyFM step context. If provided, the step is marked done immediately after the alarm is published.

alarm_or_halt(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, robot_model: str, option: str, save_log: bool, is_only_at_ui: bool, pause_option: str, title: object, content: object, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None) → None#

Raises an alarm and/or halts execution, depending on option.

Parameters:
  • robot_model – Name of the robot model.

  • option – “ALARM” (publish an alarm dialog), “HALT” (stop the step’s context), “FOLDER_HALT” (break out of the enclosing folder), or “SUB_PROGRAM_HALT” (halt the enclosing sub task).

  • save_log – If true, also emits a USER-level log entry with content (or title if content is None).

  • is_only_at_ui – If true and the step is not running from a UI execution, the step is marked done and this call is a no-op.

  • pause_option – “ALL” (pause every process) or “CURRENT” (pause only this context). Only consulted when option resolves to a pause.

  • title – Alarm dialog title (used when option is “ALARM”, and as the log fallback content when save_log is set and content is None).

  • content – Alarm dialog / log content.

  • flow_manager_args – PyFM step context. Required; the step is marked done after the alarm/halt/pause sequence completes.

all_pause(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#

Pauses every running program process on this robot.

Parameters:

flow_manager_args – Optional PyFM step context. If provided, the step’s own execution context is paused too, after the broadcast pause request.

all_stop(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#

Stops every running program process on this robot.

Parameters:

flow_manager_args – Optional PyFM step context. If provided, the step is marked done after the broadcast stop request.

before_close(self: rb_sdk.rb_sdk_cpp.RBProgramSDK) → None#
call_event_tree(*, trees, index, task_id=None, target_step_id=None, _post_run=False, flow_manager_args=None)#

Execute one event-sub-task tree from a list[rb_flow_manager.step.Step].

Parameters:
  • trees (list['rb_flow_manager.step.Step'])

  • index (int)

  • task_id (str | None)

  • target_step_id (str | None)

  • _post_run (bool)

  • flow_manager_args (rb_schemas.sdk.FlowManagerArgs | None)

change_program(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, program_id: str | None = None, program_name: str | None = None, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#
debug_variables(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, robot_model: str, option: str, is_only_at_ui: bool, variables: object, log_content: object = None, pause_option: str = 'ALL', flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#

Reports the current values of variables for debugging, then pauses.

Compares each variable’s raw (pre-evaluation) string against its evaluated JSON value; numeric values/lists are rounded to 3 decimals for display, and unchanged variables are reported as “Undefined”.

Parameters:
  • robot_model – Name of the robot model.

  • option – “DIALOG” (publish a single alarm dialog listing every variable) or “LOG” (emit one USER-level log entry per variable).

  • is_only_at_ui – If true and the step is not running from a UI execution, the step is marked done and this call is a no-op.

  • variables – Evaluated current variable values, in the same order as flow_manager_args's raw “variables” list.

  • log_content – Optional extra USER-level log entry (any value; non- str is JSON-encoded) appended after the per-variable LOG entries.

  • pause_option – “ALL” (pause every process) or “CURRENT” (pause only this context).

  • flow_manager_args – Optional PyFM step context. Required for this call to do anything; the step is marked done after pausing.

get_digital_input(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, robot_model: str) → list[int] | None#

Queries the digital input state of robot_model.

Parameters:

robot_model – Name of the robot model.

Returns:

The digital input list, or std::nullopt if the robot has no {robot_model}/get_digital_input zenoh queryable (e.g. not connected / not running).

get_rpc(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, module_name: str) → RpcManager#

Returns the RpcManager registered for module_name, creating it on first use.

Parameters:

module_name – PFM task id used as the RpcManager cache key.

Returns:

The RpcManager instance for module_name, owned by rpc_managers_.

interface(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, option: str, data: dict, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#

Dispatches a protocol interface call (Modbus/MC/XGT/socket) via the native RpcManager cached for this step’s task id (rpc_managers_).

Parameters:
  • option (str) – “MODBUS_CLIENT”, “MC_PROTOCOL”, “XGT_PROTOCOL”, or “SOCKET_INTERFACE”.

  • data (rb_schemas.fbs_types.muscat.InterfaceModbusClientPayloadTD | rb_schemas.fbs_types.muscat.InterfaceMcProtocolPayloadTD | rb_schemas.fbs_types.muscat.InterfaceXgtProtocolPayloadTD | rb_schemas.fbs_types.muscat.InterfaceSocketPayloadTD) – Protocol payload generated from manipulate.fbs. Must contain a non-empty “server_ip” and a “type” of “READ”/”WRITE” (plus “CONNECT” for SOCKET_INTERFACE).

  • flow_manager_args (rb_schemas.sdk.FlowManagerArgs | None) – Optional PyFM step context. Required for this call to do anything — if omitted, returns immediately without dispatching to any protocol. When provided, it’s forwarded to the underlying execute_* call and the step is marked done after dispatch.

Raises:

std::runtime_error – If option or data["type"] is unsupported for the given option.

log(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, content: str, robot_model: str, level: str, disable_db: bool = False, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#

Emits a program log entry.

Parameters:
  • content – Log message content.

  • robot_model – Name of the robot model this log entry is associated with.

  • level – Log level (“INFO”, “WARNING”, “ERROR”, “USER”, “DEBUG”, or “GENERAL”).

  • disable_db – Unused (kept for parity with the Python original, which also never reads this parameter).

  • flow_manager_args – Optional PyFM step context. If provided, the step is marked done immediately after the log entry is published.

make_script(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, mode: str = 'ADVANCED', contents: str | None = None, flow_manager_args: object = None) → None#

Runs a program script step, in either GENERAL or ADVANCED mode.

In GENERAL mode, flow_manager_args's “general_contents” argument is evaluated as a single expression against the step’s context (assignments are reflected into state). In ADVANCED mode, contents is compiled and executed as an arbitrary python script with variables/var, update_variable, update_var/update, get_var/get, done, pause, stop, resume, check_stop, and rb_log injected into its globals (the bridge builds that env from flow_manager_args; compile/exec runs on the PyFM side in ctx.run_advanced_script). rb_log is this SDK’s own log (RBBaseSDK::log), called as rb_log(content, robot_model, level).

Parameters:
  • mode – “GENERAL” or “ADVANCED”.

  • contents – ADVANCED-mode script source. Required when mode is “ADVANCED”.

  • flow_manager_args – PyFM step context. Required; the step is marked done when the script finishes (or immediately raises, in ADVANCED mode, since the step is still marked done before the exception propagates).

Raises:

std::runtime_error – If GENERAL mode is missing “general_contents”, or ADVANCED mode is missing contents.

plugin_execute(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, plugin_id: str, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None, **kwargs) → None#

Sends an execute request to a plugin process and waits until it reports completion (or stop). Concurrent calls for the same plugin_id are serialized so their control queryables don’t collide.

Parameters:
  • plugin_id – Target plugin id; the request is sent to “muscat/plugin/{plugin_id}/execute” and control messages are exchanged over “muscat/plugin/{plugin_id}/control”.

  • user_args – Execute request JSON object. The Python binding collects **kwargs into this object.

  • flow_manager_args – PyFM step context. Required; the step is marked done once the plugin reports “done” (directly, or by exiting its control loop after “stop”).

Raises:

std::runtime_error – If flow_manager_args is not provided, or if the plugin is not running/responding to the execute request.

set_variables(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, variables: object, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#

Initializes local task variables from their configured init values.

Parameters:
  • variables – List of variable definition dicts, each carrying an “init_value” key, in the same order as the task’s declared variables.

  • flow_manager_args – Optional PyFM step context. Required for this call to do anything — if omitted, returns immediately without touching variables. When provided, each variable is applied via flow_manager_args's local variable updater and the step is marked done afterwards.

simple_wait(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, second: float, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#

Blocks the calling thread for second seconds, polling for stop/pause requests every 1/50s. Time spent blocked inside a pause is excluded from the wait duration.

Parameters:
  • second – Seconds to wait. Must be greater than 0 when flow_manager_args is not provided (a standalone caller has no other way to be notified that the wait was skipped).

  • flow_manager_args – Optional PyFM step context. If provided, the step is marked done once the wait elapses (or immediately, if second <= 0).

Raises:

std::runtime_error – If second <= 0 and flow_manager_args is not provided.

user_input(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, robot_model: str, var_selection: object, var_form: str = 'STRING', flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#
user_select(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, robot_model: str, ask_ment: object, var_name: object, content: object, timeout: object, disconn_timeout: object, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#
wait(self: rb_sdk.rb_sdk_cpp.RBProgramSDK, *, robot_model: str, wait_type: str = 'TIME', mode: str = 'GENERAL', second: float | None = None, digital_input: rb_sdk.base_sdk.base_schema.DigitalInputConditionSchema | None = None, time_out: float | None = None, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None) → None#

Blocks until the requested wait condition is satisfied (or times out), polling for stop requests every 10ms.

Parameters:
  • robot_model – Name of the robot model (used for DIGITAL_INPUT polling).

  • wait_type – “TIME” (delegates to simple_wait()), “HOLDING” (wait while the condition holds), or “EXIT” (wait until the condition becomes true / the digital input matches).

  • mode – “GENERAL” (evaluate flow_manager_args's “condition” expression) or “DIGITAL_INPUT” (poll get_digital_input() against digital_input's expected signal pattern).

  • second – Wait duration in seconds, used only when wait_type is “TIME”.

  • digital_input – Digital input condition dict (“signal” list and optional “logical_operator”, “AND” by default). Required when mode is “DIGITAL_INPUT”.

  • time_out – Optional timeout in seconds; the wait loop breaks once elapsed time reaches this value, regardless of whether the condition was satisfied.

  • flow_manager_args – Optional PyFM step context. Required for this call to do anything — if omitted, returns immediately without waiting (despite the default of py::none(), calling this standalone is a no-op). The step is marked done once the wait loop exits.

class rb_sdk.rb_sdk_cpp.RpcManager#

Bases: pybind11_object

class rb_sdk.rb_sdk_cpp.RpcResult#

Bases: pybind11_object

property bits#
property data_bit#
property data_bit_fins#
property data_word#
property data_word_fins#
property data_word_xgt#
property error#
property payload#
property regs#
property success#
rb_sdk.rb_sdk_cpp.call_event_tree(*, trees, index, task_id=None, target_step_id=None, _post_run=False, flow_manager_args=None)#

Execute one event-sub-task tree from a list[rb_flow_manager.step.Step].

Parameters:
  • trees (list['rb_flow_manager.step.Step'])

  • index (int)

  • task_id (str | None)

  • target_step_id (str | None)

  • _post_run (bool)

  • flow_manager_args (rb_schemas.sdk.FlowManagerArgs | None)

rb_sdk.rb_sdk_cpp.execute_mc_read(*, rpc: rb_sdk.rb_sdk_cpp.RpcManager, module_name: str, server_ip: str, server_port: int, register_addr: int, address_type: str, protocol: str, function_code: int, number_of_read: int, return_variable_name: str, resolve_option: str = 'SKIP', flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None, alarm_fn: Callable[[str, str], None] = None) → rb_sdk.rb_sdk_cpp.RpcResult#

Reads MC (Mitsubishi) protocol device values.

function_code selects the command: 1 reads bit devices (read_bit), 2 reads word devices (read_word). address_type and protocol resolve the target McDeviceType and McFrameType respectively. The result is always taken from RpcResult::data_word — unlike the Python original’s data_word or data_bit fallback, a bit read does not fall back to data_bit (matches the current C++ behavior).

Parameters:
  • rpc – RpcManager handle for the target connection, obtained via RBProgramSDK::get_rpc(module_name).

  • module_name – PyFM task id identifying the calling step/task.

  • server_ip – MC server IP address.

  • server_port – MC server port.

  • register_addr – Starting device address to read from.

  • address_type – Device type: “1”/”D”, “2”/”M”, “3”/”X”, or “4”/”Y”.

  • protocol – MC frame type: “1”/”MC_1E” or “2”/”MC_3E”.

  • function_code – 1 (read_bit) or 2 (read_word).

  • number_of_read – Number of devices to read.

  • return_variable_name – PyFM variable name that will receive the read values (RpcResult::data_word).

  • resolve_option – How to handle a failed read — “SKIP” continues without effect, “STOP” raises immediately, “ASK” fires alarm_fn and pauses the PyFM context (requires flow_manager_args). Defaults to “SKIP”.

  • flow_manager_args – Optional PyFM step context. return_variable_name is written into its context and flow_manager_args.done() is called on completion (unless resolve_option is “STOP” and the read failed, which raises instead).

  • alarm_fn – Optional (title, content) callback used only when resolve_option is “ASK”.

Returns:

RpcResult from the native call (success flag plus the read values in data_word).

Raises:

std::runtime_error – If function_code is not 1 or 2, or address_type/@p protocol cannot be resolved; and, under “STOP”, if the read fails.

rb_sdk.rb_sdk_cpp.execute_mc_write(*, rpc: rb_sdk.rb_sdk_cpp.RpcManager, module_name: str, server_ip: str, server_port: int, register_addr: int, address_type: str, protocol: str, function_code: int, payload_field: Any | None, resolve_option: str = 'SKIP', flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None, alarm_fn: Callable[[str, str], None] = None) → rb_sdk.rb_sdk_cpp.RpcResult#

Writes MC (Mitsubishi) protocol device values.

function_code selects the command: 3 writes bit devices (write_bit, payload_field values restricted to 0/1), 4 writes word devices (write_word, payload_field values restricted to [-32768, 32767]). address_type also determines which native buffer the payload is sent through: “1”/”D” (word device) uses write_word, “2”/”3”/”4” or “M”/”X”/”Y” (bit devices) use write_bit.

Parameters:
  • rpc – RpcManager handle for the target connection, obtained via RBProgramSDK::get_rpc(module_name).

  • module_name – PyFM task id identifying the calling step/task.

  • server_ip – MC server IP address.

  • server_port – MC server port.

  • register_addr – Starting device address to write to.

  • address_type – Device type: “1”/”D”, “2”/”M”, “3”/”X”, or “4”/”Y”.

  • protocol – MC frame type: “1”/”MC_1E” or “2”/”MC_3E”.

  • function_code – 3 (write_bit) or 4 (write_word).

  • payload_field – List of values to write (1-40 entries), range depends on function_code as described above.

  • resolve_option – How to handle a failed write — “SKIP” continues without effect, “STOP” raises immediately, “ASK” fires alarm_fn and pauses the PyFM context (requires flow_manager_args). Defaults to “SKIP”.

  • flow_manager_args – Optional PyFM step context. flow_manager_args.done() is called on completion (unless resolve_option is “STOP” and the write failed, which raises instead).

  • alarm_fn – Optional (title, content) callback used only when resolve_option is “ASK”.

Returns:

RpcResult from the native call.

Raises:

std::runtime_error – If function_code is not 3 or 4, address_type/@p protocol cannot be resolved, or payload_field is missing/out of range; and, under “STOP”, if the write fails.

rb_sdk.rb_sdk_cpp.execute_modbus_read(*, rpc: rb_sdk.rb_sdk_cpp.RpcManager, module_name: str, server_ip: str, server_port: int, function_code: int, register_addr: int, number_of_read: int, return_variable_name: str, resolve_option: str = 'SKIP', timeout_sec: float = 1.0, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None, alarm_fn: Callable[[str, str], None] = None) → rb_sdk.rb_sdk_cpp.RpcResult#

Reads Modbus holding or input registers.

function_code selects the register type: 3 reads holding registers (READ_HOLDING), 4 reads input registers (READ_INPUT).

Parameters:
  • rpc – RpcManager handle for the target connection, obtained via RBProgramSDK::get_rpc(module_name).

  • module_name – PyFM task id identifying the calling step/task.

  • server_ip – Modbus server IP address.

  • server_port – Modbus server port.

  • function_code – 3 (READ_HOLDING) or 4 (READ_INPUT).

  • register_addr – Starting register address to read from.

  • number_of_read – Number of registers to read.

  • return_variable_name – PyFM variable name that will receive the read registers (RpcResult::regs).

  • resolve_option – How to handle a failed read — “SKIP” continues without effect, “STOP” raises immediately, “ASK” fires alarm_fn and pauses the PyFM context (requires flow_manager_args). Defaults to “SKIP”.

  • timeout_sec – Read timeout in seconds. Defaults to 1.0.

  • flow_manager_args – Optional PyFM step context. return_variable_name is written into its context and flow_manager_args.done() is called on completion (unless resolve_option is “STOP” and the read failed, which raises instead).

  • alarm_fn – Optional (title, content) callback used only when resolve_option is “ASK”.

Returns:

RpcResult from the native call (success flag plus the read registers in regs).

Raises:

std::runtime_error – If function_code is not 3 or 4; and, under “STOP”, if the read fails.

rb_sdk.rb_sdk_cpp.execute_modbus_write(*, rpc: rb_sdk.rb_sdk_cpp.RpcManager, module_name: str, server_ip: str, server_port: int, function_code: int, register_addr: int, payload_field: Any | None, resolve_option: str = 'SKIP', timeout_sec: float = 1.0, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None, alarm_fn: Callable[[str, str], None] = None) → rb_sdk.rb_sdk_cpp.RpcResult#

Writes Modbus holding registers.

function_code selects the write mode: 6 writes a single register (WRITE_SINGLE_REG), 16 writes multiple registers (WRITE_MULTI_REGS).

Parameters:
  • rpc – RpcManager handle for the target connection, obtained via RBProgramSDK::get_rpc(module_name).

  • module_name – PyFM task id identifying the calling step/task.

  • server_ip – Modbus server IP address.

  • server_port – Modbus server port.

  • function_code – 6 (WRITE_SINGLE_REG) or 16 (WRITE_MULTI_REGS).

  • register_addr – Starting register address to write to.

  • payload_field – List of register values to write (1-40 entries, each in [0, 65535]).

  • resolve_option – How to handle a failed write — “SKIP” continues without effect, “STOP” raises immediately, “ASK” fires alarm_fn and pauses the PyFM context (requires flow_manager_args). Defaults to “SKIP”.

  • timeout_sec – Write timeout in seconds. Defaults to 1.0.

  • flow_manager_args – Optional PyFM step context. flow_manager_args.done() is called on completion (unless resolve_option is “STOP” and the write failed, which raises instead).

  • alarm_fn – Optional (title, content) callback used only when resolve_option is “ASK”.

Returns:

RpcResult from the native call.

Raises:

std::runtime_error – If function_code is not 6 or 16, or payload_field is missing/out of range; and, under “STOP”, if the write fails.

rb_sdk.rb_sdk_cpp.execute_socket_connect(*, rpc: rb_sdk.rb_sdk_cpp.RpcManager, module_name: str, server_ip: str, server_port: int, resolve_option: str = 'SKIP', flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None, alarm_fn: Callable[[str, str], None] = None) → bool#

Opens a socket connection and registers the session under module_name.

Only creates the session (connect_sock()); it does not wait for a response, so unlike the other execute_* calls in this file the GIL is not released while the call runs.

Parameters:
  • rpc – RpcManager handle for the target connection, obtained via RBProgramSDK::get_rpc(module_name).

  • module_name – PyFM task id identifying the calling step/task.

  • server_ip – Socket server IP address.

  • server_port – Socket server port.

  • resolve_option – How to handle a failed connect — “SKIP” continues without effect, “STOP” raises immediately, “ASK” fires alarm_fn and pauses the PyFM context (requires flow_manager_args). Defaults to “SKIP”.

  • flow_manager_args – Optional PyFM step context. flow_manager_args.done() is called on completion (unless resolve_option is “STOP” and the connect failed, which raises instead).

  • alarm_fn – Optional (title, content) callback used only when resolve_option is “ASK”.

Returns:

true if the connection was established; false otherwise.

Raises:

std::runtime_error – Under “STOP”, if the connect fails.

rb_sdk.rb_sdk_cpp.execute_socket_read(*, rpc: rb_sdk.rb_sdk_cpp.RpcManager, module_name: str, server_ip: str, server_port: int, function_code: int, return_variable_name: str, resolve_option: str = 'SKIP', timeout_sec: float = 1.0, flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None, alarm_fn: Callable[[str, str], None] = None) → rb_sdk.rb_sdk_cpp.RpcResult#

Receives data over a socket connection.

function_code selects how the received payload is decoded before being stored: 1 keeps it as the raw byte list, 2 decodes it as a UTF-8 string.

Parameters:
  • rpc – RpcManager handle for the target connection, obtained via RBProgramSDK::get_rpc(module_name).

  • module_name – PyFM task id identifying the calling step/task.

  • server_ip – Socket server IP address.

  • server_port – Socket server port.

  • function_code – 1 (raw bytes) or 2 (UTF-8 string).

  • return_variable_name – PyFM variable name that will receive the decoded payload.

  • resolve_option – How to handle a failed receive — “SKIP” continues without effect, “STOP” raises immediately, “ASK” fires alarm_fn and pauses the PyFM context (requires flow_manager_args). Defaults to “SKIP”.

  • timeout_sec – Receive timeout in seconds. Defaults to 1.0.

  • flow_manager_args – Optional PyFM step context. return_variable_name is written into its context and flow_manager_args.done() is called on completion (unless resolve_option is “STOP” and the receive failed, which raises instead).

  • alarm_fn – Optional (title, content) callback used only when resolve_option is “ASK”.

Returns:

RpcResult from the native call (success flag plus the raw payload in payload).

Raises:

std::runtime_error – If function_code is not 1 or 2, or the payload cannot be decoded as UTF-8; and, under “STOP”, if the receive fails.

rb_sdk.rb_sdk_cpp.execute_socket_write(*, rpc: rb_sdk.rb_sdk_cpp.RpcManager, module_name: str, server_ip: str, server_port: int, function_code: int, payload: str, resolve_option: str = 'SKIP', flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None, alarm_fn: Callable[[str, str], None] = None) → rb_sdk.rb_sdk_cpp.RpcResult#

Sends data over a socket connection.

function_code selects how payload is encoded before sending: 3 (BYTES) splits payload on the delimiter read from flow_manager_args.args[“data”][“split”] and parses each token as an integer byte value; 4 (ASCII) encodes payload directly as ASCII bytes.

Parameters:
  • rpc – RpcManager handle for the target connection, obtained via RBProgramSDK::get_rpc(module_name).

  • module_name – PyFM task id identifying the calling step/task.

  • server_ip – Socket server IP address.

  • server_port – Socket server port.

  • function_code – 3 (BYTES, delimiter-split) or 4 (ASCII).

  • payload – String payload to send; interpretation depends on function_code as described above.

  • resolve_option – How to handle a failed send — “SKIP” continues without effect, “STOP” raises immediately, “ASK” fires alarm_fn and pauses the PyFM context (requires flow_manager_args). Defaults to “SKIP”.

  • flow_manager_args – Optional PyFM step context, required when function_code is 3 to look up the split delimiter. flow_manager_args.done() is called on completion (unless resolve_option is “STOP” and the send failed, which raises instead).

  • alarm_fn – Optional (title, content) callback used only when resolve_option is “ASK”.

Returns:

RpcResult from the native call.

Raises:

std::runtime_error – If function_code is not 3 or 4, the BYTES split delimiter is missing, or payload cannot be parsed/encoded; and, under “STOP”, if the send fails.

rb_sdk.rb_sdk_cpp.execute_xgt_read(*, rpc: rb_sdk.rb_sdk_cpp.RpcManager, module_name: str, server_ip: str, server_port: int, register_addr: int, cpu_type: str, device_type: str, function_code: int, number_of_read: int, return_variable_name: str, resolve_option: str = 'SKIP', flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None, alarm_fn: Callable[[str, str], None] = None) → rb_sdk.rb_sdk_cpp.RpcResult#

Reads XGT (LS Electric) protocol device values.

Only function_code 1 (read_byte) is currently supported. cpu_type and device_type resolve the target XgtCPUinfo and XgtDeviceType respectively.

Parameters:
  • rpc – RpcManager handle for the target connection, obtained via RBProgramSDK::get_rpc(module_name).

  • module_name – PyFM task id identifying the calling step/task.

  • server_ip – XGT server IP address.

  • server_port – XGT server port.

  • register_addr – Starting device address to read from.

  • cpu_type – CPU type: “XGK”, “XGI”, “XBC”, “XEC”, or “NONE”.

  • device_type – Device type; only “DB” is currently supported.

  • function_code – Must be 1 (read_byte).

  • number_of_read – Number of devices to read.

  • return_variable_name – PyFM variable name that will receive the read values (RpcResult::data_word_xgt).

  • resolve_option – How to handle a failed read — “SKIP” continues without effect, “STOP” raises immediately, “ASK” fires alarm_fn and pauses the PyFM context (requires flow_manager_args). Defaults to “SKIP”.

  • flow_manager_args – Optional PyFM step context. return_variable_name is written into its context and flow_manager_args.done() is called on completion (unless resolve_option is “STOP” and the read failed, which raises instead).

  • alarm_fn – Optional (title, content) callback used only when resolve_option is “ASK”.

Returns:

RpcResult from the native call (success flag plus the read values in data_word_xgt).

Raises:

std::runtime_error – If function_code is not 1, or cpu_type/@p device_type cannot be resolved; and, under “STOP”, if the read fails.

rb_sdk.rb_sdk_cpp.execute_xgt_write(*, rpc: rb_sdk.rb_sdk_cpp.RpcManager, module_name: str, server_ip: str, server_port: int, register_addr: int, cpu_type: str, device_type: str, function_code: int, payload_field: Any | None, resolve_option: str = 'SKIP', flow_manager_args: rb_schemas.sdk.FlowManagerArgs | None = None, alarm_fn: Callable[[str, str], None] = None) → rb_sdk.rb_sdk_cpp.RpcResult#

Writes XGT (LS Electric) protocol device values.

Only function_code 3 (write_byte) is currently supported. cpu_type and device_type resolve the target XgtCPUinfo and XgtDeviceType respectively.

Parameters:
  • rpc – RpcManager handle for the target connection, obtained via RBProgramSDK::get_rpc(module_name).

  • module_name – PyFM task id identifying the calling step/task.

  • server_ip – XGT server IP address.

  • server_port – XGT server port.

  • register_addr – Starting device address to write to.

  • cpu_type – CPU type: “XGK”, “XGI”, “XBC”, “XEC”, or “NONE”.

  • device_type – Device type; only “DB” is currently supported.

  • function_code – Must be 3 (write_byte).

  • payload_field – List of values to write (1-40 entries, each in [-32768, 32767]).

  • resolve_option – How to handle a failed write — “SKIP” continues without effect, “STOP” raises immediately, “ASK” fires alarm_fn and pauses the PyFM context (requires flow_manager_args). Defaults to “SKIP”.

  • flow_manager_args – Optional PyFM step context. flow_manager_args.done() is called on completion (unless resolve_option is “STOP” and the write failed, which raises instead).

  • alarm_fn – Optional (title, content) callback used only when resolve_option is “ASK”.

Returns:

RpcResult from the native call.

Raises:

std::runtime_error – If function_code is not 3, cpu_type/@p device_type cannot be resolved, or payload_field is missing/out of range; and, under “STOP”, if the write fails.