Skip to content

Echo server

The emulated controller used by the tests, the examples' dry runs and offline development. How to run it: Testing offline.

Reference

EchoServer

EchoServer(config_file, delay_ms=4, mode='relative', rsi_file=None, timeout_packets=None, onlysend=None)

Emulates a KUKA RSI controller for offline testing.

Initialise the echo server.

Parameters:

Name Type Description Default
config_file str

Path to RSI EthernetConfig.xml.

required
delay_ms int

Interpolation cycle in milliseconds (4 or 12 on a real controller). Doubles as the IPOC increment per cycle.

4
mode str

Correction mode ("relative" or "absolute").

'relative'
rsi_file str

Optional path to a .rsi / .rsi.xml signal-flow file. Its ETHERNET object's Timeout parameter is used as the faulty-packet budget.

None
timeout_packets int

Explicit faulty-packet budget; overrides rsi_file.

None
onlysend bool

ONLYSEND mode - stream data, expect no replies. Default: taken from the config's ONLYSEND setting.

None

receive_and_process

receive_and_process()

Reads one incoming UDP datagram (if any) and hands it to process_reply().

process_reply

process_reply(xml_string)

Parse, validate and (only if valid) apply one reply.

A reply is rejected when
  • it cannot be parsed as XML,
  • the Type attribute does not match the configured SENTYPE,
  • its IPOC is not the exact value we last transmitted.

Rejected packets increment the faulty counter and their corrections and state updates are discarded in full.

Parameters:

Name Type Description Default
xml_string str

Raw XML from the client.

required

Returns:

Type Description
bool

True if the packet was accepted and applied, False otherwise.

generate_message

generate_message()

Creates a reply XML message based on current state. Format matches KUKA RSI's expected response structure. Iterates over all state variables from the config's send_variables.

send_once

send_once()

Transmits one packet and advances the IPOC clock by one cycle.

Returns:

Type Description
str

The XML that was transmitted.

send_message

send_message()

Main loop to receive input, update state, and send reply. Runs in a background thread until stopped.

start

start()

Starts the echo server loop in a background thread.

stop

stop()

Stops the echo server and cleans up the socket.