PYME.Acquire.ActionManager module

Created on Sat May 28 23:12:24 2016

@author: david

class PYME.Acquire.ActionManager.ActionManager(scope)

Bases: object

This implements a queue for actions which should be called sequentially.

The main purpose of the ActionManager is to facilitate automated imaging by allowing multiple operations to be queued. Rather than being strictly FIFO, different tasks can be asigned different priorities, with higher priority tasks bubbling up and and being executed before lower priority tasks. This allows high priority “imaging” tasks to be inserted into a stream of lower priority “monitoring” tasks if something interesting is detected during monitoring.

An individual action is a function which can be found within the scope of our microscope object (for more details see the QueueAction method).

To function correctly the Tick() method should be called regularly - e.g. from a GUI timer.

Methods

QueueAction(functionName, args[, nice, timeout]) Add an action to the queue
Tick(**kwargs) Polling function to check if the current action is finished and, if so, start the next action if available.

Initialise our action manager

Parameters:

scope : PYME.Acquire.microscope.microscope object

The microscope. The function object to call for an action should be accessible within the scope namespace, and will be resolved by calling eval(‘scope.functionName’)

Methods

QueueAction(functionName, args[, nice, timeout]) Add an action to the queue
Tick(**kwargs) Polling function to check if the current action is finished and, if so, start the next action if available.
QueueAction(functionName, args, nice=10, timeout=1000000.0)

Add an action to the queue

Parameters:

functionName : string

The name of a function relative to the microscope object. e.g. to call scope.spoolController.StartSpooling(), you would use a functionName of ‘spoolController.StartSpooling’.

The function should either return None if the operation has already completed, or function which evaluates to True once the operation has completed. See scope.spoolController.StartSpooling() for an example.

args : dict

a dictionary of arguments to pass the function

nice : int (or float)

The priority with which to execute the function. Functions with a lower nice value execute first.

timeout : float

A timeout in seconds from the current time at which the action becomes irrelevant and should be ignored.

Tick(**kwargs)

Polling function to check if the current action is finished and, if so, start the next action if available.

Should be called regularly for a timer or event loop.