devctrl.devices.monochromator.impl.bentham_tmc300.TMC300#

class TMC300(cfg_path='system.cfg', atr_path='system.atr', tmp_dir='~/.cache/')[source]#

Bases: Monochromator

Controls the Bentham TMC300 monochromator.

The python SDK (pyBen) builds a “system model” from a config and an atr file.

This class implements changes of the grating by modifying a copy of the atr file and giving that to the SDK.

Methods

add_device

Manually add a specific device.

allow_only_dummy_devices

connect

connect_device

This function should be overridden by device implementations only, and is not intended to be used directly.

connect_dummy

Connect an instance of the device's dummy implementation

get_base_classes

Return a flat dictionary of all base classes below this class :param recurse: If True, recursively search for base classes :return: dict of {class name: class}

get_device_name

get_device_type_name

get_energy_eV

get_grating_lines_per_mm

Get the grating lines per millimeter

get_resolution_eV

get_resolution_nm

Get the monochromator resolution from the atr file

get_status

Query the status of the device and return a string describing errors.

get_wavelength_nm

is_connected

Query whether the device is (still) connected

list_devices

Get a list of all devices for this type.

reset

Initialize and park the monochromator

return_parameters

Return device parameters for saving

set_energy_eV

set_resolution_eV

set_resolution_nm

set_wavelength_nm

Changes the probe wavelength

Attributes

DEFAULT_ATR_NAME = 'system.atr'#
DEFAULT_CFG_NAME = 'system.cfg'#
ERRORS = {1: 'BI_PMC_timeout', 2: 'BI_MSC_timeout', 3: 'BI_MSD_timeout', 4: 'BI_MAC_timeout', 5: 'BI_MAC_invalid_cmd', 10: 'BI_225_dead', 11: 'BI_265_dead', 12: 'BI_267_dead', 13: 'BI_277_dead', 14: 'BI_262_dead', 20: 'BI_ADC_read_error', 21: 'BI_ADC_invalid_reading', 22: 'BI_ADC_Overload', 30: 'BI_AMP_invalid_channel', 31: 'BI_AMP_invalid_wavelength', 32: 'BI_SAM_invalid_wavelength', 33: 'BI_turret_invalid_wavelength', 34: 'BI_turret_incorrect_pos', 35: 'BI_MVSS_invalid_width', 100: 'BI_undefined_error'}#
_CLASS_TYPE = 'implementation'#
__abstractmethods__ = frozenset({})#
__annotations__ = {'_manual_devices': list[str]}#
__dict__ = mappingproxy({'__module__': 'devctrl.devices.monochromator.impl.bentham_tmc300', '__firstlineno__': 16, '__doc__': '\nControls the Bentham TMC300 monochromator.\n\nThe python SDK (pyBen) builds a "system model" from a config and an atr file.\n\nThis class implements changes of the grating by modifying a copy of the atr file and giving that to the SDK.\n', '_CLASS_TYPE': 'implementation', 'DEFAULT_CFG_NAME': 'system.cfg', 'DEFAULT_ATR_NAME': 'system.atr', '__init__': <function TMC300.__init__>, '_write_atr_file': <function TMC300._write_atr_file>, 'ERRORS': {1: 'BI_PMC_timeout', 2: 'BI_MSC_timeout', 3: 'BI_MSD_timeout', 4: 'BI_MAC_timeout', 5: 'BI_MAC_invalid_cmd', 10: 'BI_225_dead', 11: 'BI_265_dead', 12: 'BI_267_dead', 13: 'BI_277_dead', 14: 'BI_262_dead', 20: 'BI_ADC_read_error', 21: 'BI_ADC_invalid_reading', 22: 'BI_ADC_Overload', 30: 'BI_AMP_invalid_channel', 31: 'BI_AMP_invalid_wavelength', 32: 'BI_SAM_invalid_wavelength', 33: 'BI_turret_invalid_wavelength', 34: 'BI_turret_incorrect_pos', 35: 'BI_MVSS_invalid_width', 100: 'BI_undefined_error'}, 'get_status': <function TMC300.get_status>, 'is_connected': <function TMC300.is_connected>, 'return_parameters': <function TMC300.return_parameters>, 'reset': <function TMC300.reset>, '_report_errors': <function TMC300._report_errors>, 'set_wavelength_nm': <function TMC300.set_wavelength_nm>, 'get_wavelength_nm': <function TMC300.get_wavelength_nm>, 'get_grating_lines_per_mm': <function TMC300.get_grating_lines_per_mm>, 'set_resolution_eV': <function TMC300.set_resolution_eV>, 'set_resolution_nm': <function TMC300.set_resolution_nm>, '_set_resolution_nm': <function TMC300._set_resolution_nm>, 'get_resolution_nm': <function TMC300.get_resolution_nm>, '__repr__': <function TMC300.__repr__>, '_enumerate_devices': <classmethod(<function TMC300._enumerate_devices>)>, 'connect_device': <classmethod(<function TMC300.connect_device>)>, '__static_attributes__': ('_resolution_eV', 'atr_content', 'atr_original_path', 'atr_path', 'cfg_path', 'parked', 'tmp_dir', 'wavelength', 'wavelength_nm'), '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '_children': {}, '_manual_devices': ['name=TMC300', 'name=TMC300']})#
__firstlineno__ = 16#
__init__(cfg_path='system.cfg', atr_path='system.atr', tmp_dir='~/.cache/')[source]#
__module__ = 'devctrl.devices.monochromator.impl.bentham_tmc300'#
__repr__()[source]#
Returns:

The name of the device. If applicable, this should include serial port, GPIB address, etc.

__slots__ = ()#
__static_attributes__ = ('_resolution_eV', 'atr_content', 'atr_original_path', 'atr_path', 'cfg_path', 'parked', 'tmp_dir', 'wavelength', 'wavelength_nm')#
__weakref__#

list of weak references to the object

_abc_impl = <_abc._abc_data object>#
_children = {}#
_dummies_only = False#
classmethod _enumerate_devices() list[str][source]#

This function should be overridden by device implementations only, and is not intended to be used directly. Instead, use list_devices() to get a list of devices. Use enumerate_devices only directly when you only want to list devices of one specific implementation, i.e., only SR830 Lock-In: SR830._enumerate_devices() :param class_name: The name of the device class

_manual_devices: list[str] = ['name=TMC300', 'name=TMC300']#
_report_errors(after_function)[source]#
_set_resolution_nm(resolution_nm: float)[source]#

Set the monochromator bandwidth in nanometers

Changes the corresponding lines on the copy of the system.atr file. :note:`Only takes effect the next time a wavelength is set`

Parameters:

resolution_nm – Bandwidth in nanometers

Raises:

RuntimeError – If the bandwidth setting cannot be found in the ATR file

_write_atr_file()[source]#
classmethod add_device(connect_info)#

Manually add a specific device. The device will show up when list_devices() is called for the device type. Call this from the device class implementation, e.g. use ModelXYZ9000.add_device(‘GPIB:1234:5678’) to add a specific device with a fixed GPIB address. This is useful when automatic discovery is undesired/impossible, either because it is not implemented or it disturbs other devices which can’t handle a identification request. :param cls: The device implementation class :param connect_info: A string argument that is passed to the connect() method of the device implementation, when the device is being connected.

static allow_only_dummy_devices()#
classmethod connect(device_type_name: str, device_name: str | None, **kwargs) Device#
Parameters:
  • device_type_name – The name of the device class

  • device_name – The name of the device class

classmethod connect_device(device_name: str, **kwargs)[source]#

This function should be overridden by device implementations only, and is not intended to be used directly. Instead, use list_devices() to get a list of devices, and pass the selected device type and name to connect() :param device_name: The name of the device class

classmethod connect_dummy(**kwargs) Device#

Connect an instance of the device’s dummy implementation

classmethod get_base_classes(recurse=True) dict[str, type[Device]]#

Return a flat dictionary of all base classes below this class :param recurse: If True, recursively search for base classes :return: dict of {class name: class}

classmethod get_device_name() str#
Returns:

The specific type name of the device, e.g., SR830 or Keithly2600

classmethod get_device_type_name() str#
Returns:

The general type name of the device, e.g., Lock-In Amplifier or Voltmeter

get_energy_eV() float#
get_grating_lines_per_mm()[source]#

Get the grating lines per millimeter

:note:`Not yet implemented`

Returns:

Number of lines per millimeter for the current grating

Raises:

NotImplementedError – This method is not yet implemented

get_resolution_eV() float#
get_resolution_nm() float[source]#

Get the monochromator resolution from the atr file

Searches the ATR configuration file for the ‘Constant bandwidth’ setting and returns the resolution in nanometers.

Returns:

Monochromator resolution in nanometers

Raises:

RuntimeError – If the resolution cannot be determined

get_status() str[source]#

Query the status of the device and return a string describing errors. If everything is ok, empty string must be returned :return: String of device status

get_wavelength_nm()[source]#
is_connected() bool[source]#

Query whether the device is (still) connected

classmethod list_devices() list[tuple[str, str]]#

Get a list of all devices for this type. The list made up of: - Manually added devices - Available devices (those returned by _enumerate_devices) - A dummy device (if a dummy implementation exists) - List of all devices of child classes

Returns:

list of available devices

reset()[source]#

Initialize and park the monochromator

Parks the TMC300. Important to do at least once after a new lamp is started. This method builds the system model, loads the setup, initializes the device, and parks it at a safe position.

return_parameters()[source]#

Return device parameters for saving

Returns a dictionary of parameters relevant for this Bentham TMC300 monochromator. New parameters to be saved can be added to this method.

Returns:

Dictionary of device parameters with their current values

set_energy_eV(energy_eV)#
set_resolution_eV(resolution_eV)[source]#
set_resolution_nm(resolution_nm: float)[source]#
set_wavelength_nm(wavelength_nm: float)[source]#

Changes the probe wavelength