poolaction

This module is part of the Python Pool libray. It defines the class for an abstract action over a set of pool elements

Functions

Classes

get_thread_pool()[source]

Returns the global pool of threads for Sardana

Returns:the global pool of threads object
Return type:taurus.core.util.ThreadPool

PoolAction

Inheritance diagram of PoolAction
class PoolAction(main_element, name='GlobalAction')[source]

Bases: taurus.core.util.log.Logger

A generic class to handle any type of operation (like motion or acquisition)

get_main_element()[source]

Returns the main element for this action

Returns:sardana.pool.poolelement.PoolElement
main_element

Returns the main element for this action

Returns:sardana.pool.poolelement.PoolElement
get_pool()[source]

Returns the pool object for this action

Returns:sardana.pool.pool.Pool
pool

Returns the pool object for this action

Returns:sardana.pool.pool.Pool
clear_elements()[source]

Clears all elements from this action

add_element(element)[source]

Adds a new element to this action.

Parameters:element (sardana.pool.poolelement.PoolElement) – the new element to be added
remove_element(element)[source]

Removes an element from this action. If the element is not part of this action, a ValueError is raised.

Parameters:element (sardana.pool.poolelement.PoolElement) – the new element to be removed
Raises:ValueError
get_elements(copy_of=False)[source]

Returns a sequence of all elements involved in this action.

Parameters:copy_of (bool) – If False (default) the internal container of elements is returned. If True, a copy of the internal container is returned instead
Returns:a sequence of all elements involved in this action.
Return type:seq<sardana.pool.poolelement.PoolElement>
get_pool_controller_list()[source]

Returns a list of all controller elements involved in this action.

Returns:a list of all controller elements involved in this action.
Return type:list<sardana.pool.poolelement.PoolController>
get_pool_controllers()[source]

Returns a dict of all controller elements involved in this action.

Returns:a dict of all controller elements involved in this action.
Return type:dict<sardana.pool.poolelement.PoolController, seq<sardana.pool.poolelement.PoolElement>>
is_running()[source]

Determines if this action is running or not

Returns:True if action is running or False otherwise
Return type:bool
run(*args, **kwargs)[source]

Runs this action

start_action(*args, **kwargs)[source]

Start procedure for this action. Default implementation raises NotImplementedError

Raises:NotImplementedError
set_finish_hooks(hooks)[source]

Set finish hooks for this action.

Parameters:hooks (OrderedDict or None) – an ordered dictionary where keys are the hooks and values is a flag if the hook is permanent (not removed after the execution)
add_finish_hook(hook, permanent=True)[source]

Append one finish hook to this action.

Parameters:
  • hook (callable) – hook to be appended
  • permanent (boolean) – flag if the hook is permanent (not removed after the execution)
remove_finish_hook(hook)[source]

Remove finish hook.

finish_action()[source]

Finishes the action execution. If a finish hook is defined it safely executes it. Otherwise nothing happens

stop_action(*args, **kwargs)[source]

Stop procedure for this action.

abort_action(*args, **kwargs)[source]

Aborts procedure for this action

emergency_break()[source]

Tries to execute a stop. If it fails try an abort

was_stopped()[source]

Determines if the action has been stopped from outside

Returns:True if action has been stopped from outside or False otherwise
Return type:bool
was_aborted()[source]

Determines if the action has been aborted from outside

Returns:True if action has been aborted from outside or False otherwise
Return type:bool
was_action_interrupted()[source]

Determines if the action has been interruped from outside (either from an abort or a stop).

Returns:True if action has been interruped from outside or False otherwise
Return type:bool
action_loop()[source]

Action loop for this action. Default implementation raises NotImplementedError

Raises:NotImplementedError
read_state_info(ret=None, serial=False)[source]

Reads state information of all elements involved in this action

Parameters:
  • ret (dict) – output map parameter that should be filled with state information. If None is given (default), a new map is created an returned
  • serial (bool) – If False (default) perform controller HW state requests in parallel. If True, access is serialized.
Returns:

a map containing state information per element

Return type:

dict<sardana.pool.poolelement.PoolElement, stateinfo>

raw_read_state_info(ret=None, serial=False)[source]

Unsafe. Reads state information of all elements involved in this action

Parameters:
  • ret (dict) – output map parameter that should be filled with state information. If None is given (default), a new map is created an returned
  • serial (bool) – If False (default) perform controller HW state requests in parallel. If True, access is serialized.
Returns:

a map containing state information per element

Return type:

dict<sardana.pool.poolelement.PoolElement, stateinfo>

get_read_value_ctrls()[source]
read_value(ret=None, serial=False)[source]

Reads value information of all elements involved in this action

Parameters:
  • ret (dict) – output map parameter that should be filled with value information. If None is given (default), a new map is created an returned
  • serial (bool) – If False (default) perform controller HW value requests in parallel. If True, access is serialized.
Returns:

a map containing value information per element

Return type:

dict<:class:~`sardana.pool.poolelement.PoolElement`, (value object, Exception or None)>

raw_read_value(ret=None, serial=False)[source]

Unsafe. Reads value information of all elements involved in this action

Parameters:
  • ret (dict) – output map parameter that should be filled with value information. If None is given (default), a new map is created an returned
  • serial (bool) – If False (default) perform controller HW value requests in parallel. If True, access is serialized.
Returns:

a map containing value information per element

Return type:

dict<:class:~`sardana.pool.poolelement.PoolElement, sardana.sardanavalue.SardanaValue >

get_read_value_loop_ctrls()[source]
read_value_loop(ret=None, serial=False)[source]

Reads value information of all elements involved in this action

Parameters:
  • ret (dict) – output map parameter that should be filled with value information. If None is given (default), a new map is created an returned
  • serial (bool) – If False (default) perform controller HW value requests in parallel. If True, access is serialized.
Returns:

a map containing value information per element

Return type:

dict<:class:~`sardana.pool.poolelement.PoolElement`, (value object, Exception or None)>

raw_read_value_loop(ret=None, serial=False)[source]

Unsafe. Reads value information of all elements involved in this action

Parameters:
  • ret (dict) – output map parameter that should be filled with value information. If None is given (default), a new map is created an returned
  • serial (bool) – If False (default) perform controller HW value requests in parallel. If True, access is serialized.
Returns:

a map containing value information per element

Return type:

dict<:class:~`sardana.pool.poolelement.PoolElement, sardana.sardanavalue.SardanaValue >

OperationInfo

Inheritance diagram of OperationInfo
class OperationInfo[source]

Bases: object

Stores synchronization data for a certain operation

init(count)[source]

Initializes this operation with a certain count

wait(timeout=None)[source]

waits for the operation to finish

finish_one()[source]

Notifies this operation that one step was finished

acquire()[source]

Acquires this operation lock

release()[source]

Releases this operation lock

PoolActionItem

Inheritance diagram of PoolActionItem
class PoolActionItem(element)[source]

Bases: object

The base class for an atomic action item

get_element()[source]

Returns the element associated with this item

set_element(element)[source]

Sets the element for this item

element

Returns the element associated with this item

ActionContext

Inheritance diagram of ActionContext
class ActionContext(pool_action)[source]

Bases: object

Stores an atomic action context

enter()[source]

Enters operation

exit()[source]

Leaves operation