hvl_ccb.dev.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:
hvl_ccb.dev.base.SingleCommDevice
Device class for the CryLas laser attenuator.
-
property
attenuation
¶
-
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: Union[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: Union[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
¶
-
property
-
class
CryLasAttenuatorConfig
(init_attenuation: Union[int, float] = 0, response_sleep_time: Union[int, float] = 1)[source]¶ Bases:
object
Device configuration dataclass for CryLas attenuator.
-
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
: Union[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
: Union[int, float] = 1¶
-
-
class
CryLasAttenuatorSerialCommunication
(configuration)[source]¶ Bases:
hvl_ccb.comm.serial.SerialCommunication
Specific communication protocol implementation for the CryLas attenuator. Already predefines device-specific protocol parameters in config.
-
class
CryLasAttenuatorSerialCommunicationConfig
(terminator: bytes = b'', encoding: str = 'utf-8', encoding_error_handling: str = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = 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:
hvl_ccb.comm.serial.SerialCommunicationConfig
-
baudrate
: int = 9600¶ Baudrate for CryLas attenuator is 9600 baud
-
bytesize
: Union[int, hvl_ccb.comm.serial.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
: Union[str, hvl_ccb.comm.serial.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
: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1¶ CryLas attenuator uses one stop bit
-
terminator
: bytes = b''¶ No terminator
-
timeout
: Union[int, float] = 3¶ use 3 seconds timeout as default
-
-
class
CryLasLaser
(com, dev_config=None)[source]¶ Bases:
hvl_ccb.dev.base.SingleCommDevice
CryLas laser controller device class.
-
class
AnswersShutter
(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]¶ Bases:
aenum.Enum
Standard answers of the CryLas laser controller to ‘Shutter’ command passed via com.
-
CLOSED
= 'Shutter inaktiv'¶
-
OPENED
= 'Shutter aktiv'¶
-
-
class
AnswersStatus
(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]¶ Bases:
aenum.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=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]¶ Bases:
aenum.Enum
Status of the CryLas laser
-
READY_ACTIVE
= 2¶
-
READY_INACTIVE
= 1¶
-
UNREADY_INACTIVE
= 0¶
-
property
is_inactive
¶
-
property
is_ready
¶
-
-
class
RepetitionRates
(value=<object object>, names=None, module=None, type=None, start=1, boundary=None)[source]¶ Bases:
aenum.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
¶
-
close_shutter
() → None[source]¶ Close the laser shutter.
- Raises
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if success is not confirmed by the device
-
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
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if the device does not answer the query
-
laser_off
() → None[source]¶ Turn the laser off.
- Raises
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if success is not confirmed by the device
-
laser_on
() → None[source]¶ Turn the laser on.
- Raises
SerialCommunicationIOError – when communication port is not opened
CryLasLaserNotReadyError – if the laser is not ready to be turned on
CryLasLaserError – if success is not confirmed by the device
-
open_shutter
() → None[source]¶ Open the laser shutter.
- Raises
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if success is not confirmed by the device
-
set_init_shutter_status
() → None[source]¶ Open or close the shutter, to match the configured shutter_status.
- Raises
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if success is not confirmed by the device
-
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
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if the device does not confirm success
-
set_repetition_rate
(rate: Union[int, hvl_ccb.dev.crylas.CryLasLaser.RepetitionRates]) → None[source]¶ Sets the repetition rate of the internal software trigger.
- Parameters
rate – frequency (Hz) as an integer
- Raises
ValueError – if rate is not an accepted value in RepetitionRates Enum
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if success is not confirmed by the device
-
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
SerialCommunicationIOError – if com port is closed unexpectedly
CryLasLaserError – if laser_off() or close_shutter() fail
-
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
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if success is not confirmed by the device
-
update_shutter_status
() → None[source]¶ Update the shutter status (OPENED or CLOSED)
- Raises
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if success is not confirmed by the device
-
update_target_pulse_energy
() → None[source]¶ Query the laser pulse energy.
- Raises
SerialCommunicationIOError – when communication port is not opened
CryLasLaserError – if success is not confirmed by the device
-
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
-
class
CryLasLaserConfig
(calibration_factor: Union[int, float] = 4.35, polling_period: Union[int, float] = 12, polling_timeout: Union[int, float] = 300, auto_laser_on: bool = True, init_shutter_status: Union[int, hvl_ccb.dev.crylas.CryLasLaserShutterStatus] = <CryLasLaserShutterStatus.CLOSED: 0>)[source]¶ Bases:
object
Device configuration dataclass for the CryLas laser controller.
-
ShutterStatus
¶
-
auto_laser_on
: bool = True¶
-
calibration_factor
: Union[int, float] = 4.35¶
-
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
: Union[int, hvl_ccb.dev.crylas.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
: Union[int, float] = 12¶
-
polling_timeout
: Union[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
CryLasLaserNotReadyError
[source]¶ Bases:
hvl_ccb.dev.crylas.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: Union[int, float] = 0, polling_interval_sec: Union[int, float] = 1, polling_timeout_sec: Optional[Union[int, float]] = None)[source]¶ Bases:
hvl_ccb.dev.utils.Poller
Poller class for polling the laser status until the laser is ready.
- Raises
CryLasLaserError – if the timeout is reached before the laser is ready
SerialCommunicationIOError – when communication port is closed.
-
class
CryLasLaserSerialCommunication
(configuration)[source]¶ Bases:
hvl_ccb.comm.serial.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: Optional[str] = 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 = 'replace', wait_sec_read_text_nonempty: Union[int, float] = 0.5, default_n_attempts_read_text_nonempty: int = 10, port: Union[str, NoneType] = 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:
hvl_ccb.comm.serial.SerialCommunicationConfig
-
baudrate
: int = 19200¶ Baudrate for CryLas laser is 19200 baud
-
bytesize
: Union[int, hvl_ccb.comm.serial.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
: Union[str, hvl_ccb.comm.serial.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
: Union[int, hvl_ccb.comm.serial.SerialCommunicationStopbits] = 1¶ CryLas laser uses one stop bit
-
terminator
: bytes = b'\n'¶ The terminator is LF
-
timeout
: Union[int, float] = 10¶ use 10 seconds timeout as default (a long timeout is needed!)
-