mxcubecore.HardwareObjects.abstract.AbstractSampleChanger#

Description#

AbstractSampleChanger is a base class to help in the implementation of Hardware Objects for SampleChangers following the “SampleChanger Standard Interface”.

If this class is used as base class a standard class is then provided for its use by generic bricks or by MXCuBE itself. This class exposes the following API for bricks and MXCuBE:

SampleChanger - Standard Interface#

Sample Changer States#

SampleChangerState.Unknown SampleChangerState.Ready SampleChangerState.Loaded SampleChangerState.Loading SampleChangerState.Unloading SampleChangerState.Selecting SampleChangerState.Scanning SampleChangerState.Resetting SampleChangerState.Charging SampleChangerState.Moving SampleChangerState.ChangingMode SampleChangerState.StandBy SampleChangerState.Disabled SampleChangerState.Alarm SampleChangerState.Fault SampleChangerState.Initializing SampleChangerState.Closing

Commands#

load() unload() select() abort() change_mode()

get_state() get_status() is_ready() wait_ready() has_loaded_sample() get_loaded_sample()

Specifying sample locations#

The sample model in a sample changer is based in the model:

SampleChanger
Container
[Container…]

Sample

Typically for a sample changer with Pucks and Sample there is a single level for Container. Specifying a sample location will consist in giving the puck (basket) number followed by the sample number. In the location example 3:5 the fifth sample in the third puck is specified.

For other more complex constructions (for example for a plate manipulator) each nested container will be specified until getting to the sample:

In the example for a location in a plate manipulator like 1:5:2 the location specifies first plate well, fifth drop, second crystal.

Events emitted#

SampleChanger.STATE_CHANGED_EVENT SampleChanger.STATUS_CHANGED_EVENT SampleChanger.INFO_CHANGED_EVENT SampleChanger.LOADED_SAMPLE_CHANGED_EVENT SampleChanger.SELECTION_CHANGED_EVENT SampleChanger.TASK_FINISHED_EVENT

Tools for SC Classes#

  • useUpdateTimer (xml property):

    This property can accept a boolean value (True/False)

    If this property is set the HardwareObject will poll itself for state changes, information change and other needed values.

    Include a line like <useUpdateTimer>True</useUpdateTimer in the xml file

How to implement derived SC Classes#

Classes

SampleChanger(type_, scannable, *args, **kwargs)

Abstract base class for sample changers

SampleChangerMode()

Enumeration of sample changer operating modes

SampleChangerState()

Enumeration of sample changer states

class mxcubecore.HardwareObjects.abstract.AbstractSampleChanger.SampleChanger(type_, scannable, *args, **kwargs)[source]#

Bases: Container, HardwareObject

Abstract base class for sample changers

abort()[source]#

Aborts current task and puts device in safe state

assert_can_execute_task()[source]#
Raises:

(Exeption) – If sample changer cannot execute a task

assert_enabled()[source]#
Raises:

(Exception) – If sample changer is disabled.

assert_not_charging()[source]#
Raises:

(Exception) – If sample changer is not charging

chained_load(sample_to_unload, sample_to_load)[source]#

Chain the unload of a sample with a load.

Parameters:
  • sample_to_unload (tuple) – sample address on the form (component1, … ,component_N-1, component_N)

  • sample_to_load (tuple) – sample address on the form (component1, … ,component_N-1, component_N)

  • (Object) – Value returned by _execute_task either a Task or result of the operation

change_mode(mode, wait=True)[source]#

Change the mode (SC specific, imply change of the State) :param mode: Modes:

Unknown = 0 Normal = 1 Charging = 2 Disabled = 3

Parameters:

wait (boolean) – True to block until mode changed is completed, False otherwise

Rerturns:
(Object): Value returned by _execute_task either a Task

or result of the operation.

get_loaded_sample()[source]#
Returns:

(Sample) Currently loaded sample

get_sample_properties()[source]#
Returns:

With sample properties defined in Sample

Return type:

(tuple)

get_state()[source]#
Returns:

Current sample changer state

Return type:

(SampleChangerState)

get_status()[source]#
Returns:

(str) String representation of current state

Return type:

str

get_task_error()[source]#
Returns:

Description of the error of last executed task (or None if success)

Return type:

(str)

get_token()[source]#

???

has_loaded_sample()[source]#
Returns:

True if a sample is loaded False otherwise

Return type:

(boolean)

init()[source]#

HardwareObject init method

is_enabled()[source]#
Returns:

True if sample changer is enabled otherwise False

Return type:

(boolean)

is_executing_task()[source]#
Returns:

Description of the error of last executed task (or None if success).

Return type:

(str)

is_mounted_sample(sample_location)[source]#

Check if the sample is mounted. :param sample_location: Sample location to check.

Returns:

True if mounted.

Return type:

(bool)

is_normal_state()[source]#
Returns:

True if state is not in the ‘NOT USABLE’ states list.

Return type:

(bool)

is_ready()[source]#
Returns:

True if the state corresponds to READY.

Return type:

(bool)

is_task_finished()[source]#
Returns:

Description of the error of last executed task (or None if success).

Return type:

(str)

is_transient()[source]#

???

load(sample=None, wait=True)[source]#

Load a sample.

Parameters:
  • sample (tuple) – sample address on the form (component1, … ,component_N-1, component_N)

  • wait (boolean) – True to wait for load to complete False otherwise

Returns
(Object): Value returned by _execute_task either a Task or result of the

operation

reset(wait=True)[source]#

Reset the sample changer.

wait: If True wait for reset to finish otherwise return immediately

Returns:

Value returned by _execute_task either a Task or result of the

operation

Return type:

(Object)

select(component, wait=True)[source]#

Select a component.

Parameters:
  • component (Component) – Component to select

  • wait (boolean) – True to wait for selection to complete otherwise False

Rerturns:
(Object): Value returned by _execute_task either a Task or result of the

operation

set_token(token)[source]#

???

unload(sample_slot=None, wait=True)[source]#

Unload sample to location sample_slot, unloads to the same slot as it was loaded from if None is passed

Parameters:
  • sample_slot (tuple) – sample address on the form (component1, … ,component_N-1, component_N)

  • wait – If True wait for unload to finish otherwise return immediately

Returns:

Value returned by _execute_task either a Task or result of the

operation

Return type:

(Object)

update_info()[source]#

Update sample changer sample information, currently loaded sample and emits infoChanged and loadedSampleChanged when loaded sample have changed

wait_ready(timeout=None)[source]#

Wait for current sample changer operation to finish. Blocks for timeout seconds or forever if timout is None :param timeout: timeout [s]. :type timeout: int

Raises:

(Exception) – If operation lasts longer than the timeout.

wait_task_finished(timeout=None)[source]#

Wait for currently running task to finish.

class mxcubecore.HardwareObjects.abstract.AbstractSampleChanger.SampleChangerMode[source]#

Bases: object

Enumeration of sample changer operating modes

class mxcubecore.HardwareObjects.abstract.AbstractSampleChanger.SampleChangerState[source]#

Bases: object

Enumeration of sample changer states

static tostring(state)[source]#

Convert state to string