AFL.automation.instrument.NicosScriptClient#

ToDo - Add support for reading h5 data written by nicos

  • get list of files, load data by file name or data title

Classes

NicosScriptClient(*args, **kwargs)

A client for interacting with a NICOS server from python scripts or the command line.

class AFL.automation.instrument.NicosScriptClient.NicosScriptClient(*args: Any, **kwargs: Any)[source]#

A client for interacting with a NICOS server from python scripts or the command line.

livedata#

Dictionary to store live data from the NICOS server. This will only show data generated after the client has connected.

Type:

dict

status#

Current status of the client, either ‘idle’ or ‘run’.

Type:

str

messages#

Queue to store log messages.

Type:

list

livedata = {}#
status = 'idle'#
__init__()[source]#

Initialize the NicosScriptClient.

signal(name, data=None, exc=None)[source]#

Handle signals from the NICOS server.

Parameters:
  • name (str) – The name of the signal.

  • data (any, optional) – The data associated with the signal.

  • exc (any, optional) – Additional data for the signal.

log(name, txt)[source]#

Log a message.

Parameters:
  • name (str) – The name of the log entry.

  • txt (str) – The log message.

print_messages()[source]#

Print and clear the message queue.

clear_messages()[source]#

Clear the message queue.

connect(host, port, user, password)[source]#

Connect to a NICOS server.

Parameters:
  • host (str) – The hostname or IP address of the NICOS server.

  • port (int) – The port number of the NICOS server.

  • user (str) – The username for authentication.

  • password (str) – The password for authentication.

Raises:

RuntimeError – If the NICOS server protocol version is incompatible.

command(line, interactive=False)[source]#

Send a command to the NICOS server.

Parameters:
  • line (str) – The command to send.

  • interactive (bool, optional) – Whether to run the command interactively.

Returns:

The result of the command.

Return type:

any

get(parameter)[source]#

Get the value of a parameter or array

Parameters:

parameter (str) – The name of the parameter.

Returns:

The value of the parameter.

Return type:

any

blockForIdle(timeout=1800, initial_delay=5)[source]#

Block execution until the client status is ‘idle’ or a timeout occurs.

Parameters:
  • timeout (int, optional) – The maximum time to wait in seconds (default is 1800 seconds).

  • initial_delay (int, optional) – The initial delay before starting to check the status in seconds (default is 5 seconds).

Notes

This method will block the execution of the script until the client’s status becomes ‘idle’ or the specified timeout is reached. It checks the status every 0.1 seconds after the initial delay.

estop()[source]#

Emergency stop the client.

stop(after_command=True, after_scan_point=False, emergency=False)[source]#

Stop the client based on the specified conditions.

Parameters:
  • after_command (bool, optional) – If True, stop the client after the current command (default is True).

  • after_scan_point (bool, optional) – If True, stop the client after the current scan point (default is False).

  • emergency (bool, optional) – If True, perform an emergency stop (default is False).

Notes

This method allows stopping the client in different ways: - If emergency is True, an emergency stop is performed. - If after_command is True, the client stops after the current command. - If after_scan_point is True, the client stops after the current scan point.