hvl_ccb.dev.crylas.crylas

Inheritance diagram of hvl_ccb.dev.crylas.crylas

Device classes for a CryLas pulsed laser controller and a CryLas laser attenuator, using serial communication.

There are three modes of operation for the laser 1. Laser-internal hardware trigger (default): fixed to 20 Hz and max energy per pulse. 2. Laser-internal software trigger (for diagnosis only). 3. External trigger: required for arbitrary pulse energy or repetition rate. Switch to “external” on the front panel of laser controller for using option 3.

After switching on the laser with laser_on(), the system must stabilize for some minutes. Do not apply abrupt changes of pulse energy or repetition rate.

Manufacturer homepage: https://www.crylas.de/products/pulsed_laser.html

class CryLasAttenuator(com, dev_config=None)[source]

Bases: SingleCommDevice

Device class for the CryLas laser attenuator.

property attenuation: int | float
static config_cls()[source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns:

the type of the standard communication protocol for this device

set_attenuation(percent: int | float) None[source]

Set the percentage of attenuated light (inverse of set_transmission). :param percent: percentage of attenuation, number between 0 and 100 :raises ValueError: if param percent not between 0 and 100 :raises SerialCommunicationIOError: when communication port is not opened :raises CryLasAttenuatorError: if the device does not confirm success

set_init_attenuation()[source]

Sets the attenuation to its configured initial/default value

Raises:

SerialCommunicationIOError – when communication port is not opened

set_transmission(percent: int | float) None[source]

Set the percentage of transmitted light (inverse of set_attenuation). :param percent: percentage of transmitted light :raises ValueError: if param percent not between 0 and 100 :raises SerialCommunicationIOError: when communication port is not opened :raises CryLasAttenuatorError: if the device does not confirm success

start() None[source]

Open the com, apply the config value ‘init_attenuation’

Raises:

SerialCommunicationIOError – when communication port cannot be opened

property transmission: int | float
class CryLasAttenuatorConfig(init_attenuation: int | float = 0, response_sleep_time: int | float = 1)[source]

Bases: object

Device configuration dataclass for CryLas attenuator.

clean_values()[source]
force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

init_attenuation: int | float = 0
is_configdataclass = True
classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.

response_sleep_time: int | float = 1
exception CryLasAttenuatorError[source]

Bases: DeviceError

General error with the CryLas Attenuator.

class CryLasAttenuatorSerialCommunication(configuration)[source]

Bases: SerialCommunication

Specific communication protocol implementation for the CryLas attenuator. Already predefines device-specific protocol parameters in config.

static config_cls()[source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

class CryLasAttenuatorSerialCommunicationConfig(terminator: bytes = b'', encoding: str = 'utf-8', encoding_error_handling: str = 'strict', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Optional[str] = None, baudrate: int = 9600, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 3)[source]

Bases: SerialCommunicationConfig

baudrate: int = 9600

Baudrate for CryLas attenuator is 9600 baud

bytesize: int | SerialCommunicationBytesize = 8

One byte is eight bits long

force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

parity: str | SerialCommunicationParity = 'N'

CryLas attenuator does not use parity

classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.

stopbits: int | SerialCommunicationStopbits = 1

CryLas attenuator uses one stop bit

terminator: bytes = b''

No terminator

timeout: int | float = 3

use 3 seconds timeout as default

class CryLasLaser(com, dev_config=None)[source]

Bases: SingleCommDevice

CryLas laser controller device class.

class AnswersShutter(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Standard answers of the CryLas laser controller to ‘Shutter’ command passed via com.

CLOSED = 'Shutter inaktiv'
OPENED = 'Shutter aktiv'
class AnswersStatus(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Standard answers of the CryLas laser controller to ‘STATUS’ command passed via com.

ACTIVE = 'STATUS: Laser active'
HEAD = 'STATUS: Head ok'
INACTIVE = 'STATUS: Laser inactive'
READY = 'STATUS: System ready'
TEC1 = 'STATUS: TEC1 Regulation ok'
TEC2 = 'STATUS: TEC2 Regulation ok'
class LaserStatus(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Status of the CryLas laser

READY_ACTIVE = 2
READY_INACTIVE = 1
UNREADY_INACTIVE = 0
property is_inactive
property is_ready
class RepetitionRates(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Repetition rates for the internal software trigger in Hz

HARDWARE = 0
SOFTWARE_INTERNAL_SIXTY = 60
SOFTWARE_INTERNAL_TEN = 10
SOFTWARE_INTERNAL_TWENTY = 20
ShutterStatus

alias of CryLasLaserShutterStatus

close_shutter() None[source]

Close the laser shutter.

Raises:
static config_cls()[source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

static default_com_cls()[source]

Get the class for the default communication protocol used with this device.

Returns:

the type of the standard communication protocol for this device

get_pulse_energy_and_rate() tuple[int, int][source]

Use the debug mode, return the measured pulse energy and rate.

Returns:

(energy in micro joule, rate in Hz)

Raises:
laser_off() None[source]

Turn the laser off.

Raises:
laser_on() None[source]

Turn the laser on.

Raises:
open_shutter() None[source]

Open the laser shutter.

Raises:
set_init_shutter_status() None[source]

Open or close the shutter, to match the configured shutter_status.

Raises:
set_pulse_energy(energy: int) None[source]

Sets the energy of pulses (works only with external hardware trigger). Proceed with small energy steps, or the regulation may fail.

Parameters:

energy – energy in micro joule

Raises:
set_repetition_rate(rate: int | RepetitionRates) None[source]

Sets the repetition rate of the internal software trigger.

Parameters:

rate – frequency (Hz) as an integer

Raises:
start() None[source]

Opens the communication protocol and configures the device.

Raises:

SerialCommunicationIOError – when communication port cannot be opened

stop() None[source]

Stops the device and closes the communication protocol.

Raises:
property target_pulse_energy
update_laser_status() None[source]

Update the laser status to LaserStatus.NOT_READY or LaserStatus.INACTIVE or LaserStatus.ACTIVE.

Note: laser never explicitly says that it is not ready ( LaserStatus.NOT_READY) in response to ‘STATUS’ command. It only says that it is ready (heated-up and implicitly inactive/off) or active (on). If it’s not either of these then the answer is Answers.HEAD. Moreover, the only time the laser explicitly says that its status is inactive ( Answers.INACTIVE) is after issuing a ‘LASER OFF’ command.

Raises:

SerialCommunicationIOError – when communication port is not opened

update_repetition_rate() None[source]

Query the laser repetition rate.

Raises:
update_shutter_status() None[source]

Update the shutter status (OPENED or CLOSED)

Raises:
update_target_pulse_energy() None[source]

Query the laser pulse energy.

Raises:
wait_until_ready() None[source]

Block execution until the laser is ready

Raises:

CryLasLaserError – if the polling thread stops before the laser is ready

class CryLasLaserConfig(calibration_factor: int | float = 4.35, polling_period: int | float = 12, polling_timeout: int | float = 300, auto_laser_on: bool = True, init_shutter_status: int | ~hvl_ccb.dev.crylas.crylas.CryLasLaserShutterStatus = <CryLasLaserShutterStatus.CLOSED: 0>)[source]

Bases: object

Device configuration dataclass for the CryLas laser controller.

ShutterStatus

alias of CryLasLaserShutterStatus

auto_laser_on: bool = True
calibration_factor: int | float = 4.35
clean_values()[source]
force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

init_shutter_status: int | CryLasLaserShutterStatus = 0
is_configdataclass = True
classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

polling_period: int | float = 12
polling_timeout: int | float = 300
classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.

exception CryLasLaserError[source]

Bases: DeviceError

General error with the CryLas Laser.

exception CryLasLaserNotReadyError[source]

Bases: CryLasLaserError

Error when trying to turn on the CryLas Laser before it is ready.

class CryLasLaserPoller(spoll_handler: Callable, check_handler: Callable, check_laser_status_handler: Callable, polling_delay_sec: int | float = 0, polling_interval_sec: int | float = 1, polling_timeout_sec: int | float | None = None)[source]

Bases: Poller

Poller class for polling the laser status until the laser is ready.

Raises:
class CryLasLaserSerialCommunication(configuration)[source]

Bases: SerialCommunication

Specific communication protocol implementation for the CryLas laser controller. Already predefines device-specific protocol parameters in config.

READ_TEXT_SKIP_PREFIXES = ('>', 'MODE:')

Prefixes of lines that are skipped when read from the serial port.

static config_cls()[source]

Return the default configdataclass class.

Returns:

a reference to the default configdataclass class

query(cmd: str, prefix: str, post_cmd: str | None = None) str[source]

Send a command, then read the com until a line starting with prefix, or an empty line, is found. Returns the line in question.

Parameters:
  • cmd – query message to send to the device

  • prefix – start of the line to look for in the device answer

  • post_cmd – optional additional command to send after the query

Returns:

line in question as a string

Raises:

SerialCommunicationIOError – when communication port is not opened

query_all(cmd: str, prefix: str)[source]

Send a command, then read the com until a line starting with prefix, or an empty line, is found. Returns a list of successive lines starting with prefix.

Parameters:
  • cmd – query message to send to the device

  • prefix – start of the line to look for in the device answer

Returns:

line in question as a string

Raises:

SerialCommunicationIOError – when communication port is not opened

read() str[source]

Read first line of text from the serial port that does not start with any of self.READ_TEXT_SKIP_PREFIXES.

Returns:

String read from the serial port; ‘’ if there was nothing to read.

Raises:

SerialCommunicationIOError – when communication port is not opened

class CryLasLaserSerialCommunicationConfig(terminator: bytes = b'\n', encoding: str = 'utf-8', encoding_error_handling: str = 'strict', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Optional[str] = None, baudrate: int = 19200, parity: Union[str, hvl_ccb.comm.serial.SerialCommunicationParity] = <SerialCommunicationParity.NONE: 'N'>, stopbits: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = <SerialCommunicationStopbits.ONE: 1>, bytesize: Union[int, hvl_ccb.comm.serial.SerialCommunicationBytesize] = <SerialCommunicationBytesize.EIGHTBITS: 8>, timeout: Union[int, float] = 10)[source]

Bases: SerialCommunicationConfig

baudrate: int = 19200

Baudrate for CryLas laser is 19200 baud

bytesize: int | SerialCommunicationBytesize = 8

One byte is eight bits long

force_value(fieldname, value)

Forces a value to a dataclass field despite the class being frozen.

NOTE: you can define post_force_value method with same signature as this method to do extra processing after value has been forced on fieldname.

Parameters:
  • fieldname – name of the field

  • value – value to assign

classmethod keys() Sequence[str]

Returns a list of all configdataclass fields key-names.

Returns:

a list of strings containing all keys.

classmethod optional_defaults() dict[str, object]

Returns a list of all configdataclass fields, that have a default value assigned and may be optionally specified on instantiation.

Returns:

a list of strings containing all optional keys.

parity: str | SerialCommunicationParity = 'N'

CryLas laser does not use parity

classmethod required_keys() Sequence[str]

Returns a list of all configdataclass fields, that have no default value assigned and need to be specified on instantiation.

Returns:

a list of strings containing all required keys.

stopbits: int | SerialCommunicationStopbits = 1

CryLas laser uses one stop bit

terminator: bytes = b'\n'

The terminator is LF

timeout: int | float = 10

use 10 seconds timeout as default (a long timeout is needed!)

class CryLasLaserShutterStatus(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Status of the CryLas laser shutter

CLOSED = 0
OPENED = 1