herosdevices.hardware.toptica.lasersdk

Low-level communication interface with the toptica laser sdk.

Module Contents

herosdevices.hardware.toptica.lasersdk.R
class herosdevices.hardware.toptica.lasersdk.LaserSDKConnection(address: str, keep_alive: bool = True, **kwargs)[source]

A class to manage Toptica Laser SDK connections.

This class provides functionality to handle Toptica Laser SDK connections including opening/closing connections, reading data, and writing data.

Requires the toptica_lasersdk package to be installed.

Parameters:
  • address – The address of the serial socket, something like /dev/ttyUSB0.

  • keep_alive – Flag indicating whether to keep the connection open between operations.

  • **kwargs – Keyword arguments passed to toptica.lasersdk.client.NetworkConnection

address
connection
keep_alive = True
operation() collections.abc.Iterator[None][source]

Context manager for handling connection operations.

Ensures the connection is open before performing operations and closes it afterward if self.keep_alive is False.

Yields:

Yields control back to the caller for performing operations within the context.

write(message: str, read_echo: bool = False, read_line: bool = False) None | str[source]

Write a message to the attached device.

Parameters:
  • message – The message to be written. Needs to be of the form command;value;dtype, i.e. laser1:dl:cc:current-set;85.0;float to set the current of a laser diode to 85mA.

  • read_echo – If True, reads back the echo from the device after writing. Defaults to False.

  • read_line – Not used. Only for compatibility with other connection types.

Returns:

If read_echo is True, returns the echo read from the connection as string; otherwise returns None.

exec(command: str, *args, return_type: None | type[R] = None) None | R[source]

Run an lasersdk “exec” command.

Parameters:
  • command – command to run on the connected laser/DLCPro

  • args – positional arguments required as input for the given command

  • return_type – type of the returned data if data is returned (must be a builtin type like str or float)

class herosdevices.hardware.toptica.lasersdk.LaserSDKCommandQuantity(command: str, writable: bool = False, observable: bool = False, format_fun: collections.abc.Callable[[str], herosdevices.core.Any] = lambda x: ..., dtype: type = str, **kwargs)[source]

Bases: herosdevices.core.DeviceCommandQuantity

Descriptor for attaching getting/setting Toptica Laser SDK values directly to class attributes exposed to HEROs.

This class provides functionality to define a class attribute of the host object based on certain set and get commands of a device on a given interface. Defining an attribute this way makes it directly accessible to HEROS. This class behaves the same as herosdevices.core.DeviceCommandQuantity, but with adaptions to the Toptica Laser SDK.

For more details see herosdevices.core.DeviceCommandQuantity.

Parameters:
  • command – Toptica Laser SDK command to query/set the target argument. Something like laser1:dl:cc:pd.

  • writable – If the attribute can be set (True) or is read only (False).

  • observable – If True, the attribute is automatically added the the _default_observables list. See for example herosdevices.hardware.toptica.DLPro for more details.

  • **kwargs – All other arguments are passed to the parent class herosdevices.core.DeviceCommandQuantity.

observable = False
command_set = None
command_get = None
return_check = None
unit = ''
dtype = None
format_fun
value_check_fun
poll_interval_limit = 1.0
transform_fun
read_line = True
herosdevices.hardware.toptica.lasersdk.attach_laser_sdk_exec_method(cls: type, name: str, command: str, expected_args: dict | None = None, return_type: None | type[R] = None) None[source]

Attaches a method to a class which runs a toptica lasersdk “exec” command on the target device.

Typically you do not need to use this method directly as herosdevices.hardware.toptica.dlcpro.DLCCommon takes care of that. Just pass the command as additional_queries.

Parameters:
  • cls – Class to attach the method to

  • name – Name of the method

  • command – Toptica lasersdk command path that the method will execute with “exec”

  • expected_args – Dict of argument names (keys) and types (values) that the command takes

  • return_type – Type of the return data, if the command returns data.

Example

Use in the __new__ method of a class like:

def __new__(cls, *_args, **_kwargs):
    attach_laser_sdk_exec_method(cls,name="my_method",command="laser1:dl:lock:close")